当前位置: 首页 > 知识库问答 >
问题:

反应本机运行的android不工作。无法初始化类组织。科德豪斯。棒极了。运行时。调用帮助器

鲁单弓
2023-03-14

我正在尝试使用CLI方法运行react native。我还获得了react-native矢量图标,并将其链接到react-native,如traversy media的本教程所示-https://www.youtube.com/watch?v=Hf4MJH0jDb4

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:\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)

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

共有2个答案

厍建义
2023-03-14

我发现了问题所在。因为Gradle 6.3不能正确支持JDK 14,所以我安装了JDK 11 LTS。然后更新了CLI

npm install @react-native-community/cli

然后扔掉了旧项目。这是一个新的,它起作用了。这可能不是其他人的最佳解决方案,但对我来说很有效,因为我才刚刚开始。

朱自明
2023-03-14

将渐变改为6.3。我修改了文件android/gradle/wrapper/gradle wrapper。属性并将distributionUrl设置为https\://服务。格拉德尔。org/distributions/gradle-6.3-all。邮政编码

就像这样:

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

 类似资料:
  • 我安装了Android Studio,当我尝试从gradle导入项目时,会显示此解决错误: 无法加载类“org”。科德豪斯。非常棒。运行时。类型处理。ShortTypeHandling’。 我删除了我的用户中的文件。gradle文件夹,并尝试了不同的gradle版本。我不知道怎么解决这个问题。

  • 当我想运行反应-本机运行-Android命令我看到 失败:构建失败,有一个异常。 > 哪里出错了:配置根项目'reactNativeCliTest'时出现问题。 无法解析配置“:classpath”的所有依赖项。无法下载gradle core。jar(com.android.tools.build:gradle-core:2.2.3)无法获取资源的https://jcenter.bintray.c

  • 我已经创建了gwt maven项目,现在我想编译它并运行它。为了配合,我提供了作为目标,并运行,但它给我构建失败的例外: [INFO][INFO] 我不明白这里有什么问题 波姆。xml:::

  • 失败:生成失败,出现异常。 > 错误:任务“:app:installdebug”执行失败。 com.android.builder.testing.api.deviceException:没有连接的设备! 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获得完整的见解。 请访问https://help.gr

  • 建立成功 总时间:2分钟6.65秒运行C:\Users\arnold\AppData\Local\Android\sdk/平台工具/adb-s 192.168.95.101:5555反向tcp:8081 tcp:8081无法运行adb反向:spawnSync C:\Users\arnold\AppData\Local\Android\sdk/平台工具/adb eNONT在192.168.95.10

  • 我的iMac上有一个完整的react本机环境,当我运行react本机运行ios时,项目完全运行,但当我使用android执行此操作时,它不工作,metro bundler窗口打开但不工作,并且不显示任何消息。 我必须做什么? 运行“react native run android”后我的终端 运行Android系统后,我的终端的打印屏幕,以及在它下面的metro捆绑包