I'm facing a weird issue. Before I updated my Android Studio, everything went fine in flutter doctor. Once I've updated Android Studio, when I run the doctor, it's showing "Unable to find bundled Java version". I've already downloaded Java installer and installed it on my M1 Mac, but after I restarted, running flutter doctor still shows the same error. The weird thing is, when I uninstall the Arctic Fox version and re-install the older Android Studio version, everything goes fine again when running the doctor. How can I resolve this?
17 Answers
The answer is already posted here.
For Mac User:
Set Java_Home
path using below article & then after applying this command.
after that type below command in terminal:
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
flutter doctor -v
-
4it seems now flutter requires java 11 rather than java 8 since new android studio artic fox update Commented Aug 14, 2021 at 20:13
-
I just went through the process with the latest flutter and the latest android studio. The solution presented here eliminates the "unable to find java version" error but then you get a ClassNotFoundException on some XML parser classes when trying to accept licenses. That's because Android Studio now comes with Java 1 which does not have a lot of the JEE stuff anymore. The simple solution to all this is to set your JAVA_HOME env variable to any Java 8 install you may have around, and this fixes everything.– entzikCommented Aug 18, 2021 at 9:04
-
-
works for me without harming pre installed java version 11.0 Commented Aug 22, 2021 at 2:47
-
This worked for me - note I had to manually install the latest JDK first (I am using MacOS big sur) apparently it does not come installer. After that this worked perfectly. Commented Sep 5, 2021 at 7:22
If you are using Android Studio Electric Eel | 2022.1.1.
On Mac
- Open "Applications" in Finder. Then right click on Android Studio, select "Show Package Contents".
- Inside it, open the "Contents" folder. Inside it you will see folder with named "jbr".
- Simply duplicate the "jbr" folder. Then, rename the copy folder to "jre".
- Then, flutter doctor. The "Unable to find bundled Java version" warning will disappear.
Thanks to @Javi for provided with alternative method.
For Step 2 & 3, ln -s jbr jre
also can get the job done. And I think this is the best method to do.
-
6You my friend are a genius, I can confirm this was the fix for me as well on Windows 11 using Android studio 2022.1.1 thank you very much sir!– demo7upCommented Jan 14, 2023 at 9:44
-
1Hey, how did you come up with this solution? Anyway, it worked for me too.– Su MitCommented Jan 16, 2023 at 11:11
-
2
-
5Even though this fixes the problem, I'd rather create a symbolic link instead of copying the folder. This way, if something changes in the
jbr
folder, you don't need to copy the folder again. In the step 2, just typeln -s jbr jre
. This will fix the problem.– JaviCommented Jan 21, 2023 at 9:52 -
1re: soft link solution. Terminal app on Mac OS doesn't have full disk access by default which means you won't be able to create a soft link, even with a sudo. Full Disk access can be granted under System Settings under Privacy & Security.– Alex SCommented Jan 25, 2023 at 7:08
Here is a little fuller answer for everything I had to do to get Android Studio set up on my M1.
Install Android Studio to the Applications folder
Create a symbolic link to from the
jre
folder to a newjdk
folder. (Due to this bug)
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
- Set the
JAVA_HOME
environment variable
nano ~/.zshrc
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
source ~/.zshrc
Install Android SDK Command-line Tools (needed for accepting license)
At this point it should work now (assuming you've also added flutter to your path)
flutter doctor
-
The
command-line tools
is important for accepting the packages Commented Aug 17, 2021 at 10:32 -
I faced similar issue on non M1 mac. The above solution fixed. Seems like its not related to M1 chip. This simple hack solved the issue with "file bundle with java not found". Commented Sep 4, 2021 at 11:14
-
There is no
jdk' directory inside
/Applications/Android Studio.app/Contents/jre/` on my machine though. I'm also on a M1 Mac. Any idea what I might be missing?– IsuruCommented Sep 10, 2021 at 11:57 -
@Isuru, Right, that's the problem. Writing
ln -s
creates thejdk
directory as a soft linking pointing to the existingjre
directory.– SuragchCommented Sep 11, 2021 at 0:46 -
This is the Windows fix, and it appears to work for me. I am using Android Studio2022.1.1.19
- First, right-click the Android Studio icon and open the file directory(location). Your installation folder should be at "C:\Program Files\Android\Android Studio".
- When you are already at the Android Studio installation root folder, you will see two folders: "jbr" and "jre".
- Copy all the files inside the "jbr" folder to the "jre" folder, then try it again.
Note: This fix is working on my end; just comment down below if it didn`t work on your end.
-
-
-
-
-
Worked too. Android Studio 2022.2 and trying to run a Flutter 2.10 project (3.13 is the last version at the time of this comment).– quantmeCommented Oct 29, 2023 at 21:24
In my case, on a macOS Ventura with Intel processor, I had to follow the steps below in order to make Flutter work after upgrading Android Studio to Electric Eel:
cd /Applications/Android\ Studio.app/Contents/
ln -s jbr jre
flutter config --android-studio-dir /Applications/Android\ Studio.app/Contents
Step 3 was important, without it flutter doctor --android-licenses
would always fail...
-
Maybe not fully related here, as question title states M1 processor, but I still think it might be helpful to some.– ldlgdsCommented Jan 29, 2023 at 16:21
-
Works on macOS
This will link jbr
folder to jre
cd /Applications/Android Studio.app/Contents
or
cd /Applications/Android\ Studio.app/Contents
ln -s jbr jre
Result:
-
1
-
In case you face "ln: jre: Operation not permitted", simply allow Full disk access to iTerm. See osxdaily.com/2018/10/09/… Commented Mar 20, 2024 at 8:59
-
I did install a fresh version of JAVA SDK, flutter, Android Studio and run the below command directly on the terminal one by one to fix 'Unable to find bundled Java version. ' issue.
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
flutter doctor -v
Now, you should be able to see the error is disappeared in flutter doctor description in terminal.
Run Flutter doctor, if there´s an error indicating that the java bundled can´t be found (specially if you have Android Studio version Artic Fox), run this commands if using Mac:
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
Flutter Doctor
This solution is for M1 Mac User
- Find your local Java version by typing
/usr/libexec/java_home -V
. If didn't exist, install the latest ARM Java version here - Set Java_Home path (in my case jdk-17.0.1.jdk) by typing
/usr/libexec/java_home /Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home
- Type all of these in terminal
cd /Applications/Android\ Studio.app/Contents/jre ln -s ../jre jdk ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
- Finally run
flutter doctor -v
to see all the details changes
-
I typed
zsh: permission denied: /Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home
into Terminal, hoping to set the Java_Home path and it saidpermission denied /Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home
. Is there somewhere else I should type? How do I give it permission?– SamCommented Jan 14, 2023 at 14:51 -
You can us sudo:
sudo export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home
or chownsudo chown -R $(whoami) /Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home
This will give you the ownership of the directory, so you don't have to use sudo everytime you want to access it. Commented Jan 15, 2023 at 7:21
I had the same error after updating Android Studio to 2020.3.1 Patch 3 (on MAC).
After upgrading Flutter from 2.2.2 to 2.5.3 problem was solved.
I also installed "Android SDK Command-line Tools". It's installation is explained here: https://stackoverflow.com/a/68492909/6839552
The accepted solution worked with a slight modification for me. I had to add the -f (or use --force) option to make it work (this is because ln failed with file exists and I kept ignoring that - the existing file must have had a problem).
cd /Applications/Android\ Studio.app/Contents/jre
ln -s -f ../jre jdk
ln -s -f "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
flutter doctor -v
I'm running macOS Monterey
Perhaps the simplest option (MAC):
- Navigate to:
cd /Applications/Android\ Studio.app/Contents/jre
- Create a directory:
mkdir jdk
- Create a soft link:
ln -s Contents jdk/Contents
COPY folder /Applications/Android Studio Preview.app/Contents/jre/Contents to /Applications/Android Studio Preview.app/Contents/jre/jdk/Contents
-
This workaround might violates standard AS default JAVA_HOME directory, have you already tried in your local?– mochadwiCommented Jul 29, 2021 at 3:14
-
1You can check this script code,YOUR_PATH/flutter/packages/flutter_tools/lib/src/android/android_studio.dart,and find the code just like this
globals.fs.path.join(directory, 'jre', 'jdk', 'Contents', 'Home')
, then you can get what path you should set for the "doctor"– crzorzCommented Jul 29, 2021 at 3:19
It's @crzorz 's additional answer worked for me. "YOUR_PATH/flutter/packages/flutter_tools/lib/src/android/android_studio.dart". At the bottom of the file, you'll see lines similar to "globals.fs.path.join(directory, 'jre', 'jdk', 'Contents', 'Home')" which @crzorz mentioned.
These lines clearly show on MacOS (old and new versions) and other OS how "flutter doctor" finds the so-called bundled Java.
I use Android Studio Electric Eel. What I did to fix the issue was "create a symbolic link named jre pointing to jbr". Because folder jbr (JetBean Runtime) has the java.exe and other Java Runtime files, but flutter doctor still tries to find a folder named jre.
-
This is not an answer. You must comment such things! Commented Jan 18, 2023 at 4:14
Update to:
Android Estudio 2022.1 Electric eel + Java 19 + VS Code + Windows 10 x64
Before: Make sure you have JAVA_PATH correctly
1 - Run
CMD as Administrator [Not POWERSHELL, because mklink
only work for CMD]
2- Run
the mklink /d "C:\Program Files\Android\Android Studio\jre" "C:\Program Files\Android\Android Studio\jbr"
3- Run
command flutter doctor
and Problem solved, but then apears the licenses problem, so
4- Run
command flutter doctor --android-licenses
wait and accept all
Other way doesn't work, thrown a error: " bla bla bla...already exist..." why?
Because the structure of mklink
command: mklink
[OPTIONS: /d /j /h rd del]
"Path+Name folder/file you want {jre}"
"Path+Name folder/file linked {jbr}"
Traduced to human language: Make a Symbolic link [mklink /d] "there with the name jre" to the folder "that is there with the name jbr"
Make sure to use "double quotes" for the files paths and say "please" and not "Just do it" (cmd smell your hurry).
If you dont do it like this, will have problems with sdkmanager
and launch devices, because the new Android Estudio don't use jre and that's why many android devices don't launch, and have the 60 second problem.
Copying all contents of JDK and pasting it into a JRE file, worked for me.
After that, I updated my ENV path.
$JAVA_HOME
directory is used? You might wanna check your Java version is compatible with stable AS 2020.3.1 and M1 as well