JAVA_HOME is set to an invalid directory Android Studio Flutter - android-studio

type here
Since the last update of android studio to Electric Eel 2022.1.1,
I'm facing this issue while running my flutter project on my phone:
Launching lib\main.dart on Redmi Note 8 Pro in debug mode...
Running Gradle task 'assembleDebug'...
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Android\Android Studio\jre
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
And JAVA_HOME variable was sat on 'C:\Program Files\Android\Android Studio\jre'.
I've tried all possible solution that I've looked for but none of them worked.
It seemes the problem is related to the latest version of Android Studio.
What is the issue and how to solve it.

For Windows:
The problem is because of trace of old Android Studio java folder, just delete this folder and it starts working:
C:\Program Files\Android\Android Studio\jre
The new Android Studio Electric Eel is using jbr, not jre.
For macOS:
If you are using macOS replace the path in .bash_profile or .zshrc
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/Contents/Home"
with
export JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"

Related

failed to load jvm dll android studio Electric Eel

I was trying to install Android Studio Electric Eel on a laptop but after installation when I'm trying to open this error comes,
failed to load jvm dll android studio
I already,
Added JAVA_HOME in system variables,
Added path of Java bin folder,
try this, it's worked for me
just delete the jre folder and it starts working(restart android studio)...
C:\Program Files\Android\Android Studio\jre
The problem is because of traces of old Android Studio java folder,The new Android Studio Electric Eel is using jbr, not jre.
You also need to add your bin directory path in path System Variable
Edit System Variables and add your path as follow

Android studio installation folder not recognize

Android studio v4.2.1 installation folder not recognize when I select Help -> Edit Custom VM Options...
it show below path.
Whereas my Android Studio installed in C:\Android\Android Studio.
I set STUDIO_VM_OPTIONS=C:\Android\Android Studio\bin but not working.
Seems you are not installing Android Studio to the default location path which is : C:\Program Files\Android\Android Studio, and the Android SDK should be installed at : C:\Users\username\AppData\Local\Android\Sdk.
Check out this URL for guidance : https://www3.ntu.edu.sg/home/ehchua/programming/android/Android_HowTo.html#:~:text=by%20default%2C%20the%20%22Android%20Studio,Local%5CAndroid%5CSdk%20%22.
Try to re-install your Android Studio using the default options and paths.
Copy the file studio64.exe.vmoptions from the following path:
C:\Program Files\Android\Android Studio\bin
to
C:\Users\home\AppData\Roaming\Google\AndroidStudio4.2
Move your Android Studio folder to C:\Users\your.username\Android-Studio and retry
Sometimes cmd not recognize your file location , maybe permissions or other thinks.

Why is emulator in Android Studio giving the wrong path? C:\buildbot\src\android

When I start my Android Emulator for flutter, it continuously gives the following error.
Emulator: C:\buildbot\src\android\emu-master-dev\external\qemu\android\android-emugl\host\libs\Translator\GLES_V2/GLESv30Imp.cpp:glWaitSync:560 error 0x501
whereas I'm unable to locate this path on my system. I'm running Android Studio on Windows 10 Pro.
My original android location is as follows.
C:\Program Files\Android\Android Studio\bin
I upgraded Android Studio to latest version and that fixed it.

Android Studio - Error launching Studio JVM DLL Failed to load

I am trying to launch Android Studio but i get the following error:
Error launching Studio - Failed to load JVM DLL C:\Program Files\Android\Android Studio\jre\jre\server\jvm.dll If you already have a 32-bit JDK Installed, define a JAVA_HOME variable in Computed > System Properties > System Settings > Environment Variables.
Installation was without errors. OS is Windows 10 Pro
Simply try to run your Android Studio as administrator.
I had the same problem.
Try:
set environment variable JAVA_HOME for your JDK as C:\Program Files\Java\jdk(your version). (C:\Program Files\Java\jdk-17.0.5 for me)
Run Android studio as administrator.
remove file .vmoptions from path android studio/bin (
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360005146240-Error-Launching-Idea-Java-Home-
)
This point really help for me: install it! https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170

Trying to run App in Android studio 1.4.1 and having build problems

Go to run my app and i get the following errors in the log.
Error:Could not run build action using Gradle installation 'C:\Program Files\Android\Android Studio\gradle\gradle-2.4'.
Log states the following "Gradle sync failed: Could not run build action using Gradle installation 'C:\Program Files\Android\Android Studio\gradle\gradle-2.4'.
Consult IDE log for more details (Help | Show Log)"
Would anyone kindly tell me how to rectify this problem.
There are two options for you
option 1-update the gradle:
i-Get latest version supported by Android Studio from: http://www.gradle.org/downloads
ii-Extract the gradle file and install to dists folder(gradle folder): default location is: C:\Users[username]\gradle\wrapper\dists
iii-Open Android Studio: File/Settings/Gradle/Service directory path: (Change to folder you set above) and Click ok.
iv-restart Android Studio.
Option 2-Delete the .gradle folder:
default location is:
C:\Users[username]\gradle\wrapper\dists
after that open Android Studio and make a new project (might need to restart).

Resources