简体   繁体   中英

“react-native run-android” command is not working

I'm new to react native and trying to set up the environment before I start coding. Whenever I try to run the command: 'react-native run-android', it throws an error: Failed to launch emulator. Reason: No emulators found as an output of emulator -list-avds . 错误图像

I'm following the documentation but still getting the error. How do I fix this?

you should add JAVA_HOME to windows environment variables, try to install Java SE Development Kit (JDK) with Chocolatey or download from https://openjdk.java.net/projects/jdk8/

if doesn't work:

Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1, Apply and close Properties, now it works

you can use AndroidStudio for open emulator, after open emulator you can use react-native run-android , after app installed you can use react-native start for more time.

you most install JDK for run java, and set JAVA_HOME in Environment Variables .

Set the JAVA_HOME Variable To set the JRE_HOME or JAVA_HOME variable:

1.Locate your Java installation directory

If you didn't change the path during installation, it'll be something like C:\Program Files\Java\jdk1.8.0_65

You can also type where java at the command prompt.

2.Do one of the following:

Windows 7 – Right click My Computer and select Properties > Advanced

Windows 8 – Go to Control Panel > System > Advanced System Settings

Windows 10 – Search for Environment Variables then select Edit the system environment variables

3.Click the Environment Variables button.

4.Under System Variables, click New.

5.In the Variable Name field, enter either:

JAVA_HOME if you installed the JDK (Java Development Kit) or JRE_HOME if you installed the JRE (Java Runtime Environment)

6.In the Variable Value field, enter your JDK or JRE installation path.

for more see this link this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM