5

Complete Console Output is below

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...

FAILURE: Build failed with an exception.

* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 696ms

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 696ms

    at makeError (/Users/user/Desktop/sa/MyReactApp/node_modules/execa/index.js:174:9)
    at /Users/user/Desktop/sa/MyReactApp/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async runOnAllDevices (/Users/user/Desktop/sa/MyReactApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
    at async Command.handleAction (/Users/user/Desktop/sa/MyReactApp/node_modules/@react-native-community/cli/build/index.js:186:9)

Bash_profile

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export ANDROID_SDK_ROOT=$ANDROID_HOME
export ANDROID_AVD_HOME=$HOME/.android/avd
alias emulator='$ANDROID_SDK_ROOT/tools/emulator'

Requested Attachments

  1. Android SDK Link From Android Studio

enter image description here

  1. SDK Tools Installed

enter image description here

  1. npx @react-native-community/cli doctor Result

enter image description here

Installed Android Emulator Nexus 6P (Android R and Pie)

New To React Native it works perfectly on iOS but it fails to launch in Android Simulator

Tried Ways

  1. npm start
  2. npx react-native run-ios
  3. npx react-native run-android
Jatin Garg
  • 306
  • 1
  • 2
  • 16

6 Answers6

6

It is Probably because of JDK version as mention above. You can verify by running react native doctor

npx @react-native-community/cli doctor
RishabhRathod
  • 313
  • 1
  • 7
  • This Shows Android SDK is missing (But I have installed Android Studio and it has Android SDK Too . Here is my Path for Android SDK(/Users/user/Library/Android/sdk) can you help what I can do next – Jatin Garg Apr 21 '20 at 06:15
  • @jatingarg can you tell me the SDK location shown from Android Studio. Also check the directory if you can see the tools folder or any other folders missing. Share me a screenshot of your Android SDK folder in your question – Allan Joseph Apr 21 '20 at 06:26
  • what is your java version ? just run java --version and share. few issues like this were also because of java issues [check here](https://stackoverflow.com/questions/35000729/android-studio-could-not-initialize-class-org-codehaus-groovy-runtime-invokerhel) and make sure you download particluar 28.0.3 SDk Tools from android studio using additional options. – RishabhRathod Apr 21 '20 at 20:12
2

Install JDK 1.8 and setup $JAVA_HOME env variable and try to run the app again.

The error is due to lower version of JDK or JDK not installed.

Allan Joseph
  • 145
  • 9
2

your problem can be resolved just follow these steps: To jetify / convert node_modules dependencies to AndroidX Imagine you have a react-native project. One of your library dependencies converts to AndroidX., and you need to use the new version.

So now you need to convert your app to AndroidX, but many of your react-native libraries ship native Java code and have not updated. How is this done?

First, use Android Studio's refactoring tool to convert your app re: the Android developer docs npm install --save-dev jetifier npx jetify npx react-native run-android (your app should correctly compile and work) Call npx jetify run in the postinstall target of your package.json (Any time your dependencies update you have to jetify again

you can follow this link as well: https://www.npmjs.com/package/jetifier

feel free for any confusion.

  • Same Error, I followed steps on Link Still Error is same – Jatin Garg Apr 21 '20 at 16:49
  • opened Project I Android Studio. Let the Gradle to compile Successfully. Refactor->Migarate to AndoidX, Then Ran each step (4-5) steps that link has. Still error was same – Jatin Garg Apr 21 '20 at 16:50
  • 1
    you guys did read the article completely you need to install bob build tool follow the above link read all the notes given in the article or follow this link : https://github.com/react-native-community/bob/blob/master/README.md#L44 feel free for any confusion. – Malik_usman Apr 22 '20 at 07:09
  • Hi Still didnt resolved. I Added a issue in Developer Forum. https://github.com/facebook/react-native/issues/28712 – Jatin Garg Apr 22 '20 at 08:00
1

The error is due to the version of JDK or JDK not installed.

i think you need to solve in the section:

open the androind folder with android studio

then file-> project structure -> SDK location and in here you can change, in my case i change the version enter image description here

before that, for to know what was the error:

i realized what is the problem with this command

npx @react-native-community/cli doctor

i got these errors: enter image description here

rnewed_user
  • 1,386
  • 7
  • 13
0

This link is the complete solution but here is a little problem if you have win32 but if you have win64 you are good to go.

 **https://www.npmjs.com/package/jetifier#do_you_need_this**

hope this answer will be useful for you feel free for any problem.

0

Please make changes as per below to resolve this error.

Install Java SDK version: 14 or above.

JDK Download link: https://www.oracle.com/java/technologies/javase-jdk14-downloads.html

In gradle-wrapper.properties please use grade version 6.3 or above.

For e.g:distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip