javascriptandroidreact-nativeandroid-jetifier

React Native, why is react-native run-android not working?


I'm trying to run command react-native run-android but it's throwing an error. I'm following docs I followed every step but it's not working, I think it's not picking the path but it set as shown in doc. Can Anyone tell me what's wrong?

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:12536) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Jetifier found 967 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator...
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
'C:\Users\Danger' is not recognized as an internal or external command,
operable program or batch file.
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
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 17s

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

that's the error I'm getting after running react native in android


Solution

  • Do these.

    1. Make sure JDK version is 8 or newer.
    2. Make sure android path's are correctly set.
    3. Remove android/build and android/app/build folders.

    Edit: If JDK version is 14 and and gradle version is less than 6.3 You have to either downgrade JDK to 11 or upgrade gradle to above 6.3