![React-Native 错误:无法找到或加载主类 org.gradle.wrapper.GradleWrapperMain](https://linux22.com/image/1585833/React-Native%20%E9%94%99%E8%AF%AF%EF%BC%9A%E6%97%A0%E6%B3%95%E6%89%BE%E5%88%B0%E6%88%96%E5%8A%A0%E8%BD%BD%E4%B8%BB%E7%B1%BB%20org.gradle.wrapper.GradleWrapperMain.png)
我正在尝试执行 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