react本地运行的android不工作.无法初始化类org.codehaus.groovy.runtime.Invok



我正在尝试使用CLI方法运行react native。我还得到了react native矢量图标,并将其链接到react native-https://www.youtube.com/watch?v=Hf4MJH0jDb4&t=933s。我安装了安卓工作室,Gradle也全部更新到了最新版本。

Java Version
java 14.0.1 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

cmd说问题出在哪里。

* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* 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

这就是我在cmd中得到的内容。问题出在哪里?当我运行命令以开始包含上述内容时,这是我的整个控制台。

C:UsersDeveshShoppingList>react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* 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 864ms
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* 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 864ms
at makeError (C:UsersDeveshShoppingListnode_modulesexecaindex.js:174:9)
at C:UsersDeveshShoppingListnode_modulesexecaindex.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (C:UsersDeveshShoppingListnode_modules@react-native-communitycli-platform-androidbuildcommandsrunAndroidrunOnAllDevices.js:94:5)
at async Command.handleAction (C:UsersDeveshShoppingListnode_modulesreact-nativenode_modules@react-native-communityclibuildindex.js:186:9)

android模拟器启动,但不加载react应用程序或任何东西,只是在另一个窗口中加载普通模拟器和react CLI。其他人也遇到这个问题了吗?你知道怎么解决这个问题吗?

将渐变更改为6.3。我修改了文件android/gradle/wrapper/gradle-wrapper.properties,并将distributionUrl设置为https://services.gradle.org/distributions/gradle-6.3-all.zip

就像这样:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

我发现了问题所在。因为Gradle6.3没有正确支持JDK14,所以我安装了JDK11LTS。然后用更新了CLI

npm install @react-native-community/cli

然后破坏了旧项目。初始化一个新的,它成功了。这可能不是其他人的最佳解决方案,但对我来说很有效,因为我才刚刚开始。

相关内容

最新更新