Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue in setting up the Android emulator with React native

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?

like image 916
akash89 Avatar asked Mar 19 '20 08:03

akash89


2 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

like image 190
Amila Dulanjana Avatar answered Sep 17 '22 17:09

Amila Dulanjana


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.

like image 41
Aniket Avatar answered Sep 16 '22 17:09

Aniket