-4
C:\Users\ZeshanAhmed\Desktop\proj\AwesomeProject>react-native run-android
info Starting JS server...

info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...


ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the `JAVA_HOME` variable in your environment to match the
location of your Java installation.
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:

    https://facebook.github.io/react-native/docs/getting-started.html

error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.
user207421
  • 305,947
  • 44
  • 307
  • 483

1 Answers1

0

Looks like you probably don't have Java installed. If you do have Java installed, your JAVA_HOME environment variable is not set. Follow the below steps depending on whether you are doing it on linux or Windows.

If you have a terminal, open one and type echo $JAVA_HOME. It should show your java home. If not, you need to set it in the terminal using export JAVA_HOME=/Path/to/your/Java/home

If you are using Windows, these are the steps - taken from here

Open the Control Panel (Win⊞ + R, type Control Panel, press Enter), and navigate to System and Security > System.

Click on Advanced system settings link in the top left.

Click on the Environment Variables button. A new window will pop up.

In the bottom pane labeled System variables, click the New… button. For the variable name, enter JAVA_HOME.

For the variable value, paste the path to your Java installation path (mostly something like C:\Program Files\Java\jre1.8.X_XXX or C:\Program Files\Java\jdk1.8.X_XXX)

Ashish
  • 209
  • 1
  • 10