Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have react native version 0.42.0. My project was working fine with this.

Recently I upgraded to react-native version 0.43.1. and now when I do

react-native run-android

I am stuck with the error.

JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
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/android-setup.html

I have followed the instruction for upgrading from https://facebook.github.io/react-native/docs/upgrading.html

I googled the issue. Gone through the following links none of it worked for me.

  1. Could not find or load main class org.gradle.wrapper.GradleWrapperMain

  2. Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

  3. How/when to generate Gradle wrapper files?

any kind of help/guidance will be helpfull for me.

like image 245
chetan Avatar asked Apr 20 '17 13:04

chetan


People also ask

How do you make a Gradle wrapper?

Just add wrapper task to build. gradle file and run this task to get the wrapper structure. task. Add the resulting files to SCM (e.g. git) and from now all developers will have the same version of Gradle when using Gradle Wrapper.

What version of Gradle do I have?

In Android Studio, go to File > Project Structure. Then select the "project" tab on the left. Your Gradle version will be displayed here.


3 Answers

Please check your gradle-wrapper.jar from gradle/wrapper folder.

I got the same error as you and I changed the jar with complete one.

I also changed one line in the gradle-wrapper.properties file with *distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip, gradle will download itself.

like image 68
Mabel Eain Avatar answered Oct 19 '22 08:10

Mabel Eain


react-native upgrade

Running this command might fix your issue. In my case, it did. But make sure to have a backup of Android and iOS folder in case you modified it.

like image 39
Akhilesh Sinha Avatar answered Oct 19 '22 09:10

Akhilesh Sinha


I fixed this issue doing these two simple steps:

1) Delete Android and iOS folders

2) Execute the next line

react-native eject

3) Run!

react-native run-android
like image 3
MattNT Avatar answered Oct 19 '22 09:10

MattNT