React-Native Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

I'm trying do the get started react-native tutorial for Ubuntu, I already have installed nodejs, the react-native command line interface, a JDK, and the Android Studio. Already set up the environment variables, so when I try run react-native run-android, this error appears:

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:
error Command failed: ./gradlew app:installDebug

and I can't find the solution for this.

1 Answer

So what I did was to download this JAR file (gradle-wrapper.jar) and placed it inside android/gradle/wrapper then I went back to the project directory and did:

npm install 

I then changed directory to android by doing:

cd android

Then I ran the following commands

chmod +x ./gradlew
xattr -l ./gradlew

Now i went back to the project directory and ran react-native run-android

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like