首页 > 解决方案 > 如何在反应原生中解决(无法初始化类 org.codehaus.groovy.reflection.ReflectionCache)问题

问题描述

$ npx react-native run-android info 运行 jetifier 将库迁移到 AndroidX。您可以使用“--no-jetifier”标志禁用它。Jetifier 找到 864 个文件来转发-jetify。使用 4 个工作人员... info 正在启动 JS 服务器... info 正在启动模拟器... 错误 无法启动模拟器。原因:无法在 30 秒内启动模拟器。警告 请手动启动模拟器或连接设备。否则,应用程序可能无法启动。信息 正在安装应用程序...

FAILURE:构建失败并出现异常。

在 1m 23s 内构建失败

错误 无法安装应用程序。确保您已设置 Android 开发环境:https ://facebook.github.io/react-native/docs/getting-started.html#android-development-environment 。使用 --verbose 标志运行 CLI 以获取更多详细信息。错误:命令失败:gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE:构建失败并出现异常。

在 1m 23s 内构建失败

at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (E:\work\react-native\AwesomeProject1\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)

标签: androidreact-native

解决方案


我想我有同样的问题。安装 RN(2020 年 5 月 20 日)后,我遇到了这个错误。我在https://github.com/gradle/gradle/issues/10248上找到了这个解决方案。

简而言之:

  1. 转到/android/gradle/wrapper/gradle-wrapper.properties您的 RN 项目中的文件

  2. 找到以 开头的这一行distributionUrl。将 gradle 版本更改为gradle-6.3-all.zip.

在我的项目中,它是:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip

我把它改成:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip

而已。


推荐阅读