JAVA_HOME is set to an invalid directory , WHY? - flutter

I have set JAVA_HOME in my system
ERROR: JAVA_HOME is set to an invalid directory: C:\Users\Yazan\Downloads\jdk-19.0.2
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
in android studio and I get error I'm restart the device but the same problem stay.

Make sure you've extracted the zip, and it will look like

Related

An error occurred while running subprocess cordova just because of version problem

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=c:\Users\krishna kale\AppData\Local\Android\Sdk (DEPRECATED)
Requirements check failed for JDK 1.8.x! Detected version: 17.0.1
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.
[ERROR] An error occurred while running subprocess cordova.
getting this problem I didnt want to chnage my envirment variable is there any way to build this by changing dependencies in Application?
why this problem is occures?
If you are using ionic 1 - 3, you need to change the environment variables. I have tested Ionic 3 with other java version other than 1.8, and it didn't work.
The newer java version has a new path created under "System variables" > "Path" on the top.
You can retain 2 java versions and revert back to your current java version (17.0.1) once you have built your app.
You can follow these steps:
Download and Install Java SDK 1.8 from the official website.
Once installed, it should be saved in C:/Program Files/Java directory
Go to your Environment Variables > System variables
Click on "New.." to create a new variable.
Variable name = JAVA_HOME and Variable value = C:\Program Files\Java\jdk1.8.0_321 or check on your directory.
Then double click on "Path" variable under System variables.
Click "New" and add %JAVA_HOME%\bin
Once created, select the newly created environment and move it to the very top (Make sure that it's above C:\Program Files\Common Files\Oracle\Java\javapath)
Reverting back to original version
Go to System variables and double click on "Path"
Remove the newly created variable = %JAVA_HOME%\bin
You should get back your original java version.

Gradle get wrong JAVA_HOME value

I try to run "ionic capacitor run". It is an Ionic 5 Capacitor proejct.
Java installed in c:\Program Files\Java\jdk1.8.0_311 and c:\Program Files\Java\jre1.8.0_311.
When I set JAVA_HOME to C:\Program Files\Java\jdk1.8.0_311\bin I have got this error:
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_311\bin
[capacitor] Please set the JAVA_HOME variable in your environment to match the
[capacitor] location of your Java installation.
When I set to C:\Program Files\Java\jdk1.8.0_311 (without \bin suffix) I have got this error:
[capacitor] FAILURE: Build failed with an exception.
[capacitor]
[capacitor] * What went wrong:
[capacitor] Supplied javaHome must be a valid directory. You supplied: C:\Program Files\Java\jdk-16.0.2
The 1.16 version was installed earlier but I uninstalled and installed 1.17.
Finally I end up with 1.8 because I have got an Ionic 4 cordova project which not work with Java 1.17.
I uninstalled/reinstalled Java, set environment variables in users and/or system settings and restarted windows several times, but I still don't know where this C:\Program Files\Java\jdk-16.0.2 value come from.
My Ionic4 (cordova) project works fine, can find the right value of JAVA_HOME and can build the app.
First start with echo %JAVA_HOME% and echo %PATH% , to see what your current Java JDK is set too in the environment and the path.
When setting the environment value use C:\Program Files\Java\jdk1.8.0_311 don't add the \bin that you include in the path, Set the path C:\Program Files\Java\jdk1.8.0_311\bin or %JAVA_HOME%\bin, Start with the first one to test.
! Important referring to the path on System variables ,Don't confuse it for the User variables path
Once you have changed the values for both environment value and path save and apply, open a new terminal for the new changes to take effect , Then run echo %JAVA_HOME% and echo %PATH% again if correct.

JAVA_HOME Flutter SDK

when using the command flutter doctor --android-licenses
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk-12.0.2
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
I did everything needed and the problem was not solved
Anyone here for help?

Gradle failed to fetch dependencies | Resolution failed -in Unity3d

This error occurs when I try to build&Run my game with Unity. I've also imported the GooglePlayServices/ads from here and also have the latest android sdk and jdk-8u144.
Here is the Error Log:
Gradle failed to fetch dependencies
Failed to run 'Temp\PlayServicesResolverGradle\gradlew.bat -b Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts. gradle --no-daemon "-PANDROID_HOME=C:/Users/rfkha/AppData/Local/Android/sdk1" "- PTARGET_DIR=C:\Users\rfkha\Documents\Space Shooter\Assets\Plugins\Android" "- PMAVEN_REPOS=https://maven.google.com" "- PPACKAGES_TO_COPY=com.google.android.gms:play-services-ads:11.2.2"'
stdout:
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.
stderr:
exit code: 1
UnityEngine.Debug:LogError(Object)
GooglePlayServices.PlayServicesResolver:LogDelegate(String, LogLevel)
Google.JarResolver.PlayServicesSupport:Log(String, LogLevel, Boolean)
GooglePlayServices.<GradleResolution>c__AnonStorey14:<>m__20(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey15:<>m__29()
GooglePlayServices.PlayServicesResolver:PumpUpdateQueue()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
2nd Error:
Resolution failed
Failed to fetch the following dependencies:
com.google.android.gms:play-services-ads:11.2.2
UnityEngine.Debug:LogError(Object)
GooglePlayServices.PlayServicesResolver:LogDelegate(String, LogLevel)
Google.JarResolver.PlayServicesSupport:Log(String, LogLevel, Boolean)
GooglePlayServices.ResolverVer1_1:LogMissingDependenciesError(List`1)
GooglePlayServices.<DoResolutionUnsafe>c__AnonStorey17:<>m__26(List`1)
GooglePlayServices.<GradleResolution>c__AnonStorey14:<>m__20(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey15:<>m__29()
GooglePlayServices.PlayServicesResolver:PumpUpdateQueue()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
add JAVA_HOME to your environment variables for mine it is C:\Program Files\Java\jdk1.8.0_144 It worked for me maybe it will for you.
For me latest Google Play Services resolver cannot copy library play-services-ads.aar to /Assets/Plugins/Android. I have to copy it manually from sdk folder:
sdk\extras\google\m2repository\com\google\android\gms\play-services-ads
to my
/Assets/Plugins/Android folder.
Delete all Google AdS files from the Asset Name folder and re-import the Google AdS package.
Or
-Right click on "my computer" and go to properties.
-Go to the Advanced tab
-Click on the Environmental Variables button
-Find the JAVA_HOME variable under System Variables
-Change the value to wherever this file actually exists for you. (for me it was C:\Program Files\Java\jdk-10)
-Restart Unity
I had to add the Jdk address as given in unity->Edit->preferences
and paste the address in the JAVA_HOME variable value.
then I restart my system and it fetched all the android dependencies and started working.
if it does not start fetching on its own you can force resolve the android dependencies.Assets->ExternalDependencyManager->AndroidResolver->force Resolve.

getting error at a ionic build

[
I am getting error what shown in image
not able to build
You haven't provided enough details to answer your question, still I wanna give it a try.
From docs have you done?
-Set the JAVA_HOME environment variable to the location of your JDK installation
-Set the ANDROID_HOME environment variable to the location of your Android SDK installation
-It is also recommended that you add the Android SDK's tools and platform-tools directories to your PATH
ref
HTH! Thanks.