0

I am trying to run a React native app with this command

npx react-native run-android --variant=stagingDebug --appId com.ursafe_staging

But getting this wrong environment path error

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

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://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installStagingDebug -PreactNativeDevServerPort=8081

Here is my environment path looks like

enter image description here

and this one

enter image description here

Still getting the error when I run the command.

Auvee
  • 95
  • 2
  • 15

1 Answers1

3

JAVA_HOME shouldn’t point to the bin directory. It should point to the JDK installation path.

It should be: C:\Program Files\Java\jdk1.8.0_202, also you don't need JRE if you already have %JAVA_HOME%\bin, see https://www.baeldung.com/java-home-on-windows-7-8-10-mac-os-x-linux

JuanMoreno
  • 2,498
  • 1
  • 25
  • 34