0

I am currently trying to run react native application but I am getting this error in windows 10.

ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_251;

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
    at checkExecSyncError (child_process.js:630:11)
    at execFileSync (child_process.js:648:15)
    at runOnAllDevices (C:\Users\User\Desktop\crate\crate\code\mobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
    at buildAndRun (C:\Users\User\Desktop\crate\crate\code\mobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:179:41)
    at C:\Users\User\Desktop\crate\crate\code\mobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:133:12
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Command.handleAction (C:\Users\User\Desktop\crate\crate\code\mobile\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:182:9)

I already install java and its working like in this image

Also, I run emulator before using this code react-native run-android like in this image it also giving me this error but the emulator working.

Failed to open /qemu.conf, err: 2

What the wrong move that I did in this situation?

Good man
  • 33
  • 7

2 Answers2

0

You can checkout the same question at this. Edit your environmental variable.

  1. Go to User Variables and Edit the path and add %JAVA_HOME%\bin.
  2. Now in your system variable environments: edit the path and click new and add this C:\Program Files\Java\jdk1.8.0_241\bin
  3. Again in system variable environment click on the path and click on new add this line C:\Program Files (x86)\Common Files\Oracle\Java\javapath
  4. Now save and restart your system. this would help you.
Anwer Solangi
  • 148
  • 3
  • 9
0

You need to setup the JAVA_HOME environment variable that will be called when running react native android build.

Setup guide for JAVA_HOME.