Reputation: 231
I'm trying to do the Android tutorial for React Native, but I'm hitting a wall. All of the requirements for React Native to work are good to go, and I've followed the Android Setup instructions.
I do not have a .bashrc, so I made one and put export ANDROID_HOME=/usr/local/opt/android-sdk
in there, but realized when I did echo $ANDROID_HOME
, I got nothing in return. I also don't have a .profile, so I added it to my bash_profile, and it now returns the path with echo.
I have installed
as well as
I installed the Intel HAXM kernel extension and created an AVD using the same parameters shown in the setup instructions.
I then started the emulator for the device I created, opened a new tab in the terminal and ran react-native run-android
, and that's when I hit the error.
Starting JS server...
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, see the error above.
I have created two different React Native projects with just the skeleton, and I get the error with both, which is making me believe I'm doing something wrong. Has anyone else run into this error or have any idea what might be going on?
Note: It runs fine iOS-wise with XCode
Update:
So someone else sent me a new React Native project that they created on their machine. I downloaded and unzipped it in my Downloads folder. After opening it, I npm install
ed. I then started the emulator and ran react-native run-android
. It worked. So I tried the same thing with the same file in the folder that it should be in. And then I got the error. So it seems that it might have something to do with my environment? In both of these folders, node and npm versions are the same (node v4.1.0 and npm 2.14.5).
Upvotes: 10
Views: 17980
Reputation: 1
Re-install Android Studio works for me, and I don't know why.
In my case, the first app that generated from react-native init
runs into this error. Maybe it's because I made a mistake on the first installation, so make sure to follow the sequence in their official document:
https://reactnative.dev/docs/environment-setup
Upvotes: 0
Reputation: 881
Run react-native upgrade It worked for me as I faced this issue at the initial stage. I was able to create the project but due to this org.gradle.wrapper version issue, I was getting the same error.
In case you have faced this issue in the middle of the project, take the backup of your android and ios folder before running the above command.
Upvotes: 7
Reputation: 2783
You may need to generate the gradle wrapper files by running gradle wrapper
at the project root. See How/when to generate Gradle wrapper files?
Upvotes: 4