I have completely followed Setting up the development environment for the react-native project, now when I am running the first app from Andriod studio run BUTTON it installs and runs perfectly. The problem comes when I run the command yarn react-native run-android it throws the following error:
info JS server already running
info Installing the app...
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk-15.0.1;C:\Program Files\Java\jdk-15.0.1\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. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this co
snapshot is here
My jdk path:
C:\Program Files\Java\jdk-15.0.1;
C:\Program Files\Java\jdk-15.0.1\bin;
My question is:
If the jdk path is invalid then why it is running in android studio?
It seems the terminal caches the earlier environment variables.
Before moving ahead make sure you have already changed the correct path for JAVA_HOME.
Now, Open Visual code and close the terminal, and reopen it (ctrl + ~)
error should be gone
You should edit your path as "C:\Program Files\Java\jdk-15.0.1" bin is not required.
To set JAVA_HOME
1-Search for Environment Variables
2-Under system variables click new
3-In the variable name enter JAVA_HOME, in the variable value enter the JDK path which is "C:\Program Files\Java\jdk-15.0.1"
I was getting this error in flutter. I deleted the "JAVA_HOME" "C:\Program Files\Java\jre7" value that I wrote earlier in the system variables section under the environment variables menu. I ran the terminal again and ran "flutter doctor --android-licenses" in the terminal. Problem solved.
Related
I installed java 8 in my Mac Big sur. I want to execute gradlew farmrun command, but it is showing that my java_home is set to an invalid directory. But I already have my java_home location in bash_profile and path is set properly.
Not able to execute gradle command - picture
Java home was set properly - picture
I am trying to write a script to automate my build process and push builds every so often. So ever everything seems to be working except for my JAVA_HOME environment variable.
When building the app normally from command line I specify my JAVA_HOME as:
/Applications/"Android Studio.app"/Contents/jre/jdk/Contents/Home
However if I add this as an environment variable to my launchctl.plist I get the following error:
ERROR: JAVA_HOME is set to an invalid directory: /Applications/"Android Studio.app"/Contents/jre/jdk/Contents/Home
This directory does exist and works fine when building the app normally.
If I do not specify the JAVA_HOME then I get the following error on building my app:
General error during semantic analysis: Unsupported class file major version 60.
Is there something I am doing wrong or can change to allow launchd to either build without the specified JAVA_HOME or to recognize the JAVA_HOME I am setting?
Add the code below to your environment's path .zshenv file in your home directory.
Run source ~/.zshenv to update terminal or Quit the terminal and reopen it again
Android Studio Dolphin and below:
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
Android Studio Electric Eel and above:
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home
I get a ionic project from a person, and I want to debug it in a real android device.
I use this command:
ionic cordova run android --device --verbose
And in the end I get these error messages:
Preparing Firebase on Android
No scripts found for hook "before_compile".
Failed to find 'JAVA_HOME' environment variable. Try setting it manually.
CordovaError: Failed to find 'JAVA_HOME' environment variable. Try setting it manually.
I have JAVA_HOME set, indeed if I do echo $JAVA_HOME I get:
/usr/lib/jvm/java-1.11.0-openjdk-amd64
According to Failed to find 'JAVA_HOME' environment variable. Try setting it manually post, I also tried adding bin folder to JAVA_HOME variable, without any success.
If I also try java -version and javac -version I get success messages.
SOLVED
Version 10.0.0 of Cordova requires jdk version 8. That's it.
I have this working and for a long time was all cool, then at some point it stopped working without me having touched it. I see this error:
ERROR building one of the platforms: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Detected 'android' command at C:\Users\Tower\bin but no 'tools' directory found near.
Try reinstall Android SDK or update your PATH to include path to valid SDK directory.
When I do echo $ANDROID_HOME I see:
C:\Users\Tower\AppData\Local\Android\android-sdk\platform-tools;C:\Users\Tower\AppData\Local\Android\android-sdk\tools
which is correct and I have the android sdk. When I do echo $JAVA_HOME it shows:
C:\Progra~1\Java\jdk1.7.0_79;C:\Progra~1\Java\jdk1.7.0_79\bin
which is also correct. I have reinstalled both the Java JDK and the Android SDK. I am running this on Windows 10, X64.
In variable ANDROID_HOME must be only path to the root directory of android-sdk i.e. C:\Users\Tower\AppData\Local\Android\android-sdk.
In JAVA_HOME also must be only path to JDK root directory i.e. C:\Progra~1\Java\jdk1.7.0_79.
This PATHs C:\Users\Tower\AppData\Local\Android\android-sdk\platform-tools;C:\Users\Tower\AppData\Local\Android\android-sdk\tools must be in PATH System Environment Variable.
And this path to jdk bin directory C:\Progra~1\Java\jdk1.7.0_79\bin must be in PATH Environment Variable.
Edit:
PATH should include ; not :
I tried to run ionic build android in windows cmd and got the error message:
"Your Java_Home is invalid : C:\Program Files\Java\jdk1.8.0.40\bin"
I already set Java_Home environment variable to "C:\Program Files\Java\jdk1.8.0_40"
How do I resolve this?
Make sure that in a new console window the output of echo %JAVA_HOME% is really "C:\Program Files\Java\jdk1.8.0_40" so you know your changes of the environment variables are in effect.
If you change environment variables, those console windows that are already open are not updated to reflect your changes. Always open a new console window then.