0

I recently installed React Native on my Windows PC and I created a project but when i try with react-native run-android for android emulator it shows me:

C:\ReactNative\testproj>react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 855 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...

ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files (x86)\Java

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:629:11)
    at execFileSync (child_process.js:647:13)
    at runOnAllDevices (C:\ReactNative\testproj\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
    at buildAndRun (C:\ReactNative\testproj\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
    at then.result (C:\ReactNative\testproj\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Please help

5
  • Your JAVA_HOME is set incorrectly, go through the setup again, everything should works... Commented Sep 13, 2019 at 1:07
  • Sir how do you mean "go through the setup again"? I browse my JAVA_HOME path in env like this C:\Program Files (x86)\Java\jre1.8.0_221, is it correct? Commented Sep 13, 2019 at 1:10
  • 1
    thewindowsclub.com/set-java_home-in-windows-10 Maybe this will help! Check out what is missing there... Commented Sep 13, 2019 at 1:26
  • It works like a charm! Thank you Sir! Commented Sep 13, 2019 at 1:31
  • Glad that helped! Do mark my answer as solution please :) Commented Sep 13, 2019 at 1:37

1 Answer 1

1

Your JAVA_HOME is set incorrectly, go through the setup again, everything should works... You can refer to this and check what is missing...

Sign up to request clarification or add additional context in comments.

1 Comment

For me, it worked after updating nodejs to latest version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.