gpt4 book ai didi

java - 命令失败 : gradlew. bat installDebug

转载 作者:太空宇宙 更新时间:2023-11-03 12:26:08 27 4
gpt4 key购买 nike

在开发应用程序时,我遇到了以下错误。我尝试将 Java 版本从 11 降级到 8,但这没有帮助。

FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 15s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

Command failed: gradlew.bat installDebug

Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:616:11)
at Object.execFileSync (child_process.js:634:13)
at runOnAllDevices (C:\Users\samie\Documents\React Native\auth\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (C:\Users\samie\Documents\React Native\auth\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (C:\Users\samie\Documents\React Native\auth\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at process._tickCallback (internal/process/next_tick.js:68:7)

最佳答案

我是如何解决这个问题的:

首先,确保我设置了 %java_home% 变量并且 %path% 包含了 java sdk。 How to setup Java environment variables

其次,转到您的 android 文件夹并运行此命令:

C:\Projects\myproject\android>gradlew.bat app:installDebug.

Unzipping C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip to C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv Exception in thread "main" java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.(ZipFile.java:225) at java.util.zip.ZipFile.(ZipFile.java:155) at java.util.zip.ZipFile.(ZipFile.java:169) at org.gradle.wrapper.Install.unzip(Install.java:215) at org.gradle.wrapper.Install.access$600(Install.java:27) at org.gradle.wrapper.Install$1.call(Install.java:75) at org.gradle.wrapper.Install$1.call(Install.java:48) at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69) at org.gradle.wrapper.Install.createDist(Install.java:48) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

如您所见,我的 gradle 下载已损坏。您所要做的就是删除此文件夹并重新运行命令。

C:\Projects\myproject\android>gradlew.bat app:installDebug

Downloading https://services.gradle.org/distributions/gradle-4.10.2-all.zip ............................................................................................................... Unzipping C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv\gradle-4.10.2-all.zip to C:\Users\codeb.gradle\wrapper\dists\gradle-4.10.2-all\9fahxiiecdb76a5g3aw9oi8rv

Welcome to Gradle 4.10.2!

Here are the highlights of this release: - Incremental Java compilation by default - Periodic Gradle caches cleanup - Gradle Kotlin DSL 1.0-RC6 - Nested included builds - SNAPSHOT plugin versions in the plugins {} block

For more details see https://docs.gradle.org/4.10.2/release-notes.html

现在,您可以回到您的 React Native 项目并运行

react-native run-android

info JS server already running. info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...

Task :app:installDebug 01:03:18 V/ddms: execute: running am get-config 01:03:18 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1 01:03:18 V/ddms: execute: returning Installing APK 'app-debug.apk' on 'Pixel_2_API_28(AVD) - 9' for app:debug 01:03:18 D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554' 01:03:18 D/Device: Uploading file onto device 'emulator-5554' 01:03:18 D/ddms: Reading file permision of C:\Projects\xx\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------ 01:03:18 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk" 01:03:19 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1 01:03:19 V/ddms: execute: returning 01:03:19 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk" 01:03:19 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1 01:03:19 V/ddms: execute: returning Installed on 1 device.

在 9 秒内取得成功 27 个可操作任务:1 个已执行,26 个是最新的 运行信息 C:\Users\codeb\AppData\Local\Android\Sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081 信息启动应用程序 模拟器 5554 (C:\Users\codeb\AppData\Local\Android\Sdk/platform-tools/adb -s emulator-5554 shell am start -n com.myproject/com.myproject.MainActivity)...开始: Intent { cmp=com.myproject/.MainActivity }

enter image description here

关于java - 命令失败 : gradlew. bat installDebug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54776936/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com