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.
Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
How/when to generate Gradle wrapper files?
any kind of help/guidance will be helpfull for me.
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.
In Android Studio, go to File > Project Structure. Then select the "project" tab on the left. Your Gradle version will be displayed here.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With