android - 如何在反应原生中解决(无法初始化类 org.codehaus.groovy.reflection.ReflectionCache)问题
问题描述
$ npx react-native run-android info 运行 jetifier 将库迁移到 AndroidX。您可以使用“--no-jetifier”标志禁用它。Jetifier 找到 864 个文件来转发-jetify。使用 4 个工作人员... info 正在启动 JS 服务器... info 正在启动模拟器... 错误 无法启动模拟器。原因:无法在 30 秒内启动模拟器。警告 请手动启动模拟器或连接设备。否则,应用程序可能无法启动。信息 正在安装应用程序...
FAILURE:构建失败并出现异常。
出了什么问题:无法初始化类 org.codehaus.groovy.runtime.InvokerHelper
尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
在https://help.gradle.org获得更多帮助
在 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:构建失败并出现异常。
出了什么问题:无法初始化类 org.codehaus.groovy.runtime.InvokerHelper
尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
在https://help.gradle.org获得更多帮助
在 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)
解决方案
我想我有同样的问题。安装 RN(2020 年 5 月 20 日)后,我遇到了这个错误。我在https://github.com/gradle/gradle/issues/10248上找到了这个解决方案。
简而言之:
转到
/android/gradle/wrapper/gradle-wrapper.properties
您的 RN 项目中的文件找到以 开头的这一行
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
而已。
推荐阅读
- jquery - 已添加具有相同键的项目 - AJAX - jQuery
- javascript - W3 自动幻灯片 2 在同一页面上
- python - 在python中按单元格值的列索引号
- html - 如何将 JSON 结构表示为 HTML 中的组织树?
- python - 为 s3 存储桶中的对象生成预签名 url 并在 aws lambda 中执行 301 重定向
- android - 当我运行“flutter build aot --debug”错误?
- git - 使用 Docker Container Sonar Scanner 的 Jenkins Pipeline 中的 SonarQube 分析 Git 存储库会引发错误 - 无法获取 uid/gid
- reactjs - Jest webpack 4 babel 7 syntaxError 'import' inside .test.js 文件
- java - 如何将 jpg 图像压缩到精确大小或更小?
- javascript - 如何将“child.vue”加载到正确的“parent.vue”位置