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

相關內容