Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native run-android Fails MacOS

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
like image 699
Jatin Garg Avatar asked Sep 01 '26 23:09

Jatin Garg


2 Answers

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

npx @react-native-community/cli doctor
like image 142
RishabhRathod Avatar answered Sep 04 '26 12:09

RishabhRathod


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.

like image 32
Allan Joseph Avatar answered Sep 04 '26 14:09

Allan Joseph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!