java - React Native 和 Android Studio:应用无法构建。错误:命令失败:gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
问题描述
你好,我是 React Native 的新手。我正在尝试使用 Android 模拟器在 Windows 操作系统中使用 React Native 运行我的 Android 应用程序。我按照这里的说明https://reactnative.dev/docs/environment-setup但我收到了这些错误:
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 8 workers...
info JS server already running.
* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
info Successfully launched emulator.
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 2s
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
这是我的 gradle 属性:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip
我的 Java JDK 版本是 15.0.2
我尝试将 gradle 属性更改为早期版本,但它不允许我,因为最低版本是 6.5 版本。
有人可以帮我吗?
解决方案
命令:
cd ProjectFolder && cd android && ./gradlew clean
如果不成功,请尝试以 npx react-native start --reset-cache 启动
如果使用博览会:expo start r -c
推荐阅读
- arrays - Swift映射数组意外的参数类型
- python - 如何使倒计时显示在 tkinter 窗口而不是我的 cmd 中?
- ios - 将 CoreStore SQLiteStore 移动到另一个位置
- android - 访问mysql时无法补偿时差
- java - 无法移除 Camel Quartz 路线
- javascript - 在 DOM 中呈现表格后,AngularJS 将带有链接的单元格链接到表格中
- sql - 仅使用 select 语句模拟表
- reactjs - 无法解析 '@material-ui\core\Box' 中的 '@material-ui/styles/styled'
- java - 从项目和变量替换生成 Maven 原型
- asp.net-core-mvc - ASP.NET Core MVC 2.2 进程内托管 - 请求中止 CancellationToken 不起作用