react-native run-android 不起作用。无法初始化类 org.codehaus.groovy.runtime.InvokerHelper

Dev*_*mar 1 java android gradle reactjs react-native

我正在尝试使用 CLI 方法运行 react-native。我还获得了 react-native-vector-icons 并将其链接为按照本教程从 traversy media - https://www.youtube.com/watch?v=Hf4MJH0jDb4&t=933s进行反应。我安装了 android studio,并且 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)
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

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

C:\Users\Devesh\ShoppingList>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:\Users\Devesh\ShoppingList\node_modules\execa\index.js:174:9)
    at C:\Users\Devesh\ShoppingList\node_modules\execa\index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async runOnAllDevices (C:\Users\Devesh\ShoppingList\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
    at async Command.handleAction (C:\Users\Devesh\ShoppingList\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:186:9)

Run Code Online (Sandbox Code Playgroud)

android 模拟器启动但不加载反应应用程序或任何东西,只是简单的模拟器和另一个窗口中的反应 CLI。其他人也遇到过这个问题吗?你知道如何解决这个问题吗?

小智 10

将 gradle 更改为 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
Run Code Online (Sandbox Code Playgroud)