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

I am trying to make an Android tutorial for React Native, but I am hitting the wall. All the requirements for React Native to work are good, and I followed the instructions for installing Android . I do not have .bashrc, so I did one and put export ANDROID_HOME=/usr/local/opt/android-sdk there, but when I did echo $ANDROID_HOME , I didn’t get anything in return. I also do not have .profile, so I added it to my bash_profile and now returns the path with an echo.

I have installed

  • Android SDK Build-tools version 23.0.1
  • Android 6.0 (API 23)
  • Android Support Repository

and

  • Intel x86 Atom system image (for Android 5.1.1 - API 22)
  • Intel x86 Emulator Accelerator (HAXM Installer)

I installed the Intel HAXM kernel extension and created the AVD using the same parameters as the installation instructions.

Then I launched the emulator for the device I created, opened a new tab in the terminal and launched react-native run-android , and 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 created two different React Native projects with only a skeleton, and I get an error with both, which makes me think that I'm doing something wrong. Does anyone else encounter this error or have an idea of ​​what might happen?

Note. It works great with the iOS interface with Xcode


Update:

So, someone sent me a new React Native project, which they created on their machine. I downloaded and unpacked it into the My Files folder. Having opened it, I npm install ed. Then I launched the emulator and launched react-native run-android . It worked. So I tried the same with the same file in the folder in which it should be. And then I got an error. It seems like this might have something to do with my environment? In both of these folders, the versions of node and npm are the same (node ​​v4.1.0 and npm 2.14.5).

+7
android main react-native
source share
1 answer

You may need to generate gradle shell files by running gradle wrapper in the root of the project. See How / When to Create Gradle Wrapper Files?

+3
source share

All Articles