React-Native 错误:无法找到或加载主类 org.gradle.wrapper.GradleWrapperMain

React-Native 错误:无法找到或加载主类 org.gradle.wrapper.GradleWrapperMain

我正在尝试执行 Ubuntu 的 react-native 入门教程,我已经安装了 nodejs、react-native 命令行界面、JDK 和 Android Studio。已经设置了环境变量,所以当我尝试运行时react-native run-android,出现此错误:

info Starting JS server...
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug

我找不到解决方案。

答案1

所以我做的是下载此 JAR 文件 ( gradle-wrapper.jar)并将其放在里面android/gradle/wrapper然后我回到项目目录并执行:

npm install 

然后我通过执行以下操作将目录更改为 android:

cd android

然后我运行了以下命令

chmod +x ./gradlew

xattr -l ./gradlew

现在我回到项目目录并运行react-native run-android

相关内容