Issue in setting up the Android emulator with React native

Viewed 8184

I am fairly new to React native and trying to set up Android environment with Visual studio. All the installation has been fairly successful, however, when I try to run the sample app on the android emulator executing the npx react-native run-android command it shows below error -

'C:\Users\Home' 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..

Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
        at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:43)
        at org.codehaus.groovy.reflection.GroovyClassValueFactory.<clinit>(GroovyClassValueFactory.java:35)
        at org.codehaus.groovy.reflection.ClassInfo.<clinit>(ClassInfo.java:109)

However, when i execute adb devices on visual studio, it shows the list of emulator connected -

List of devices attached
emulator-5554   device

What could be the possible reason? Is this because my users name is Home PC? (Is this because there is a space in between) and it is not able to get the correct path?

3 Answers

This is because your java version is updated to the latest version and gradle is not supported with the installed version. what you can do is update the gradle as well

  1. So go to gradle/wrapper folder inside the android folder
  2. Edit gradle-wrapper.properties file and replace distributionUrl with following value https\://services.gradle.org/distributions/gradle-6.3-all.zip

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

I too faced the same issue.The problem is with the JDK. From JDK 14 i downgraded to JDK 11(LTS) version. And it worked. Hope it helps.

Install Java 8 version, which is available Java 8 download

Gradle is not keeping up with the Java Latest versions, so roll back to previous versions

Related