I installed Android Studio 4.1 and tried to run the existing project. But it gives an error like this:
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.
You have to set the JAVA_HOME Environment Variable.
On Windows, I solved the issue as follows:
Download the Java JDK from here and install it. (This links to version 15, which requires you to create an account in order to download. Version 16 is available to download without creating an account, but it has caused me an error that required me to downgrade.)
Set the "JAVA_HOME" Environment Variable:
Open Windows Search, type in “env”, and choose “Edit the system environment variables”.
Click on "Environment Variables...".
Click on "New".
Fill in the "variable name" field with "JAVA_HOME".
Fill in the "variable value" with the path to where Java is installed on your computer. (for me it was under "C:\Program Files\Java\<jdkversion>".)
Click "OK" and close all dialogs.
Restart your IDE / Terminal. (do not skip this step)
On Ubuntu 20.04 with Android 4.1, this error can be solved using the Snap version with:
flutter config --android-studio-dir=/snap/android-studio/current/android-studio
For Windows :
flutter config --android-studio-dir="C:\Program Files\Android\Android Studio"
This command works fine if you have Android Studio installed. Flutter can understand the configurations of the Android Studio and you don't have to provide JAVA_HOME anymore.
Edit (Bonus) :
Also, download "Android SDK Command-line Tools" in android studio for android-licenses. Steps are shown in the image below.
You need to install Java JDK software which is required for the android studio.
sudo apt install openjdk-11-jdk
UPDATE: run flutter upgrade to upgrade to Flutter 1.22.2, which fixes compatibility issues with Android Studio 4.1. See related Flutter release.
This issue has been resolved v
See this issue regarding Android Studio 4.1 and Flutter
You can either downgrade back to Android Studio 4.0.2 or you can
install the latest JDK and update your JAVA_HOME variable and
PATH (OS dependent).
Note that if you choose to continue using 4.1 instead of downgrading,
flutter doctor will tell you Android Studio is not installed.
You need to run flutter config --android-studio-dir='<path to android studio>' in order to fix this issue. flutter doctor will now also
incorrectly report that the Flutter and Dart plugins are not
installed even if they are - you can ignore this.
Install Android Studio (skip this step if you already installed)
Goto
C:\Program Files\Android\Android Studio\jre and copy the path.
Make New variable called "JAVA_HOME". And paste above path as the variable value.
I set my JAVA HOME to the path,
/snap/android-studio/97/android-studio/jre/
Then I set my android studio config in flutter by using this command:
flutter config --android-studio-dir=/snap/android-studio/current/android-studio
My system is :
Ubuntu 20.04 with Flutter plugin version as 4.1,
In Mac:
In your terminal run
ECHO $JAVA_HOME
This will bring up the current path of java home.Pay close attention to the path that the terminal outputs.In my case i had System/Library instead of /Library/.../... typo as my path.So i simply corrected this in bash_profile.
If your path is correct but the error persists,
Right Click On Finder
Go To Folder
Bash_Profile
Add or Edit the Java Home Path
The path you add here should be the one your terminal output when you ran Echo $Java_Home..As long as this path that was echoed was/is correct..the below steps should fix the issue.
Then open your zshrc in a similar manner as you did with bash_profile and add the home path to the file.
You can also edit the bash_profile and zshrc files in your text editor.These files can be displayed using cmd + shift + . in your home folder.
After that,save,exit the terminal, close android studio and restart your machine.
Read this Article to learn more.
Locate where your Android Studio is installed.
For me C:\Program Files\Android\Android Studio
Check if the jre folder exists, Create a new folder called jre
Copy the contents of the jbr folder and paste them into the jre folder.
Check by running flutter doctor, and Restart IDE.
Thanks: roufy235 {cause}
For ubuntu 20.04 this solution will be appropriate: -
This link solved my problem. In short I would recommend to follow the simple steps, i.e.
Upgrade the flutter using flutter upgrade
Set the path of the flutter flutter config --android-studio-dir="/path/to/android/studio/"
Set the path in bashrc file by opening bashrc file(it is a hidden file)
export JAVA_HOME="/path/to/android/studio/jre/"
choco install javaruntime
If you use choco package manager. It will set the vars automatically.
This issue can also be caused if you have updated your Android Studio.
In that case.
For Windows
First Open the Users\username\AppData\Local\Google directory on your PC/Laptop and make sure to Delete the older version of your Android Studio.
e.g, Current version of Android studio is Electric Eel (2022.1).
Delete any other older version from that directory accordingly and restart your PC or Laptop.
Then try running your project.
Install openjdk-8 ....
You have to restart your terminal, the issue will persist even after download if you don't restart the terminal.
Follow react native guide to download openjdk for your environment. ...
https://reactnative.dev/docs/environment-setup
For Windows this worked
Go to C:\Program Files\Android\Android Studio.
Copy all the files inside of jbr directory.
Paste all the files into jre directory.
Then run flutter doctor. The issue will go away.
D:\Flutterproject\rechyriedapp>flutter doctor -v
[√] Flutter (Channel stable, 3.3.8, on Microsoft Windows [Version 10.0.22621.1105], locale en-IN)
• Flutter version 3.3.8 on channel stable at C:\flutter_windows_3.3.8\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 52b3dc25f6 (3 months ago), 2022-11-09 12:09:26 +0800
• Engine revision 857bd6b74c
• Dart version 2.18.4
• DevTools version 2.15.0
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\USER\AppData\Local\Android\Sdk
• Platform android-TiramisuPrivacySandbox, build-tools 33.0.0
X No Java Development Kit (JDK) found; You must have the environment variable JAVA_HOME set and the java binary in your PATH. You can download the JDK from https://www.oracle.com/technetwork/java/javase/downloads/.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.4)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.4.33213.308
• Windows 10 SDK version 10.0.22000.0
[!] Android Studio (version 2022.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
X Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
[√] Connected device (4 available)
• CPH2095 (mobile) • 86db9605 • android-arm64 • Android 12 (API 31)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.1105]
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.120
• Edge (web) • edge • web-javascript • Microsoft Edge 109.0.1518.55
[√] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 2 categories.
After that copy all file from jbr to jre
D:\Flutterproject\rechyriedapp>flutter doctor -v
[√] Flutter (Channel stable, 3.3.8, on Microsoft Windows [Version 10.0.22621.1105], locale en-IN)
• Flutter version 3.3.8 on channel stable at C:\flutter_windows_3.3.8\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 52b3dc25f6 (3 months ago), 2022-11-09 12:09:26 +0800
• Engine revision 857bd6b74c
• Dart version 2.18.4
• DevTools version 2.15.0
Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\USER\AppData\Local\Android\Sdk
• Platform android-TiramisuPrivacySandbox, build-tools 33.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.4)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.4.33213.308
• Windows 10 SDK version 10.0.22000.0
[√] Android Studio (version 2022.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
[√] Connected device (4 available)
• CPH2095 (mobile) • 86db9605 • android-arm64 • Android 12 (API 31)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.1105]
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.120
• Edge (web) • edge • web-javascript • Microsoft Edge 109.0.1518.55
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Download Liberica JDK and on installation it will automatically set JAVA_HOME environment variable.
Now you just go to Android Studio -> Project Structure -> SDK -> Point all jdk path to liberica jdk installation directory and apply.
You are done. Just restart android studio and gradle command will work.
Android Device Manager prevents me from creating an Android Device because of an incompatible JDK. However, maui-check shows me that i've got OpenJDK 11.0 installed.
Image of error message and maui-check.
Image of device I'm trying to create.
I've tried the "Install and configure Microsoft Mobile OpenJDK" but going through that it just shows me that everything is installed correctly.
Image of JDK install confirmation.
What exactly am I missing here, do I have to install a previous version of the JDK?
Download OpenJDK 8.0.41 from here
Unzipped files in Program Files > JDK > OpenJDK_8.0.41
Update JDK location in Visual Studio 2022, go to Tools > Xamarin > set above folder path in Java Development Kit Location
Original solution
I am building a plugin for Android Studio using IntelliJ but it always shows this error when I try to load it on Android Studio. Unless I set STUDIO_JDK to the jdk1.8 path.
com.intellij.diagnostic.PluginException: MyComponent :
Unsupported major.minor version 52.0
So I wonder what JDK will android studio pick up by default when STUDIO_JDK is not set.
It says
Unsupported major.minor version 52.0
you should try using jdk 1.8 with different major.minor version (other than 52.0)
I found the answer to this question later. If you open "About Android Studio" you can see JRE 1.6. It means Android Studio is running on java 1.6 environment by default, no matter what "JDK" you are using for development.
Of course there are ways to change this. You can put the jdk path in STUDIO_JDK and run Android Studio with that(initiate from terminal where you set STUDIO_JDK).
As a consequence of this, you will have to use JDK 1.6 when you develop a plugin for Android Studio so that it can work on the default setting.
Android Studio running on JRE 1.6 by default.I assumed that u have multi JDK and to change this JRE on Android Studio you need to delete/move default JDK (1.6). OSX :
sudo mv /Library/Java/JavaVirtualMachines/1.6.0.jdk /tmp
Finally check on "About Android Studio"
When I tried to install the JDK, it was installed but in start->java Development Kit: I faced with "empty"word.
But when I went to cmd and writed javac version or java version I saw true results and when I tried to install SDK for programming android with eclipse or install android studio I had not any problem for installing
But after installing when I created a new project in both softwares I had problems.
What I must do? Every time I try to install JDK it is installed as now.
I'm having an issue with Android Studio 1.0.1. I downloaded and installed it on a MacBook running Yosemite 10.10.1. When I tried to make a 'Hello World' application, it complained that it requires JDK7 to compile android-21. I had JDK6 installed. So I upgraded Java, and I figured why not just get the newest version and so I installed JDK8. Then, I uninstalled and reinstalled Android Studio and restarted the computer. When I run java -version, the terminal tells me that I'm running version 8. However, my directory structure still looks like /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/.... Android Studio still doesn't like it and complains that I need JDK7. I tried editing the plist file for Android Studio and changing the JDK to 1.8 from 1.6 and this did not work. That was everything I could find on the internet so far. I was thinking I could uninstall Java and then install JDK7 but I don't have much experience with that as I'm a Linux user and so I'm clueless as to how to do a few things on Mac, like an equivalent of apt-get uninstall java in order to actually try this out. Alternatively, I'm not sure what program to drag to the Trash to uninstall. How can I resolve this?
Have JDK 1.7 installed and make JAVA_HOME variable point to the JDK 1.7 directory then Android Studio will find your JDK 1.7 following your JAVA_HOME variable