4

I am new to the react native. I am using a linux machine. I am trying to run an application.

Now, Here what I have done ,

I already have java installed in my machine .So, that time I have added,

in my profile

I have following env variables .

export JAVA_HOME='/usr/local/java'
export PATH=$PATH:$HOME/bin:$JAVA_HOME/jdk1.8.0_121/bin

Now, after that I have installed the android studio in my one of folders,

which is /home/softwares/android-studio.

That time I have added the env variables in the profile file.which are

export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

Now, my project folder is like ,

/home/projectWork/native/app

Added the script in the package.json file , but there

it is giving me this error .

JS server not recognized, continuing with build...
Building and installing the app on the device (cd android && ./gradlew installDebug)...

ERROR: JAVA_HOME is set to an invalid directory: /usr/local/java

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

Now, I am not getting a way to resolve this issue . Can any one help me with this ?

ganesh kaspate
  • 1
  • 9
  • 41
  • 88

3 Answers3

0

I think you need to set your JAVA_HOME to the actual JDK:

export JAVA_HOME='/usr/local/java/jdk1.8.0_121'
Dennis Griesert
  • 161
  • 1
  • 2
  • 7
0

For windows user that is downgrading from JDK 17 to JDK 8, you need to ensure a few things:

  1. Set the java home and path correctly.
  2. Remove JDK 17 folder from program files path.
0

You just need to set the JAVA_HOME in your Environemnt. For Linux users. check these solutions: How to set JAVA_HOME in Linux for all users

mtz1406
  • 75
  • 1
  • 10