JAVA_HOME Flutter SDK - flutter

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?

Related

JAVA_HOME is set to an invalid directory , WHY?

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

Setting up the Android Studio directory on Flutter Doctor

I'm setting up an application development environment with Flutter.
I'm having trouble installing Android Studio: I can't set the directory where Android Studio is installed. I've got an error, as shown in the picture. How do I find the correct directory?
You default Android Studio directory should be C:\Program Files\Android\Android Studio.
If you are searching for the Android SDK location, check out here.
The warning/error you are getting on flutter doctor is telling you that he cannot find Android Studio in the path C:\Program, this means you will need to set it manually. To do it, run the following command(s) with the correct path.
flutter config --android-studio-dir "[YOURPATH]"
flutter config --android-sdk "[YOURPATH]"
This should be the expected output of the flutter doctor
Remember to use those " " to indicate the path of Android Studio, otherwise you'll have this output, that is not what we want: Setting "android-studio-dir" value to "C:\Program".
flutter config --android-studio-dir = C:\Program Files\Android\Android Studio
Which unfortunately does not work because of empty space which breaks the tree structure
To resolve this, type the command below which will reset the default.
flutter config --android-studio-dir=""

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 error when running Flutter code with Android Emulator

I am setting Flutter for the first time and I keep getting this error when trying to run the Flutter code on a Pixel 2 emulator:
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk-16.0.1\jdk-16.0.1
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I tried deleting and reinstalling Android Studio and Java SDK, but it does not solve anything.
I tried setting the JAVA_HOME variable in environmental variables with the following path:
C:\Program Files\Java\jdk-16.0.1\jdk-16.0.1
...but nothing, same error.
Thanks for your help
Important Notice:
My android sdk is installed on the D partition, while the Java sdk is on the C drive. Does it matter ?
Open powershell and write java --version
If you dont get the version try to add again the Java_home to path
Nevertheless, I think java home should be on C:\Program Files\Java\jdk-16.0.1\jdk-16.0.1\bin directory

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.