93

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?

3

17 Answers 17

194

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
7
  • 4
    it 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.
    – entzik
    Commented Aug 18, 2021 at 9:04
  • Working on Mac OS Commented Aug 20, 2021 at 11:32
  • 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.
    – deadant88
    Commented Sep 5, 2021 at 7:22
95

If you are using Android Studio Electric Eel | 2022.1.1.

On Mac

  1. Open "Applications" in Finder. Then right click on Android Studio, select "Show Package Contents".
  2. Inside it, open the "Contents" folder. Inside it you will see folder with named "jbr".
  3. Simply duplicate the "jbr" folder. Then, rename the copy folder to "jre".
  4. 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.

7
  • 6
    You 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!
    – demo7up
    Commented Jan 14, 2023 at 9:44
  • 1
    Hey, how did you come up with this solution? Anyway, it worked for me too.
    – Su Mit
    Commented Jan 16, 2023 at 11:11
  • 2
    This is the only working solution for me.
    – Hammas Ali
    Commented Jan 17, 2023 at 4:50
  • 5
    Even 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 type ln -s jbr jre. This will fix the problem.
    – Javi
    Commented Jan 21, 2023 at 9:52
  • 1
    re: 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 S
    Commented Jan 25, 2023 at 7:08
53

Here is a little fuller answer for everything I had to do to get Android Studio set up on my M1.

  1. Install Android Studio to the Applications folder

  2. Create a symbolic link to from the jre folder to a new jdk folder. (Due to this bug)

cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
  1. Set the JAVA_HOME environment variable
nano ~/.zshrc
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
source ~/.zshrc
  1. Install Android SDK Command-line Tools (needed for accepting license)

  2. At this point it should work now (assuming you've also added flutter to your path)

flutter doctor
5
  • 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?
    – Isuru
    Commented Sep 10, 2021 at 11:57
  • @Isuru, Right, that's the problem. Writing ln -s creates the jdk directory as a soft linking pointing to the existing jre directory.
    – Suragch
    Commented Sep 11, 2021 at 0:46
  • This works for me Commented Sep 29, 2021 at 20:50
28

This is the Windows fix, and it appears to work for me. I am using Android Studio2022.1.1.19

  1. 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".
  2. When you are already at the Android Studio installation root folder, you will see two folders: "jbr" and "jre".
  3. 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.

7
  • worked for me, but why?! Commented Mar 15, 2023 at 14:40
  • @Sheldeeb, then, thats good! Commented Mar 31, 2023 at 0:20
  • This did not work for me
    – MrMoxy
    Commented May 8, 2023 at 17:23
  • Worked for me been facing this for 3 days
    – amr samy
    Commented Oct 11, 2023 at 7:23
  • 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).
    – quantme
    Commented Oct 29, 2023 at 21:24
16

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:

  1. cd /Applications/Android\ Studio.app/Contents/
  2. ln -s jbr jre
  3. flutter config --android-studio-dir /Applications/Android\ Studio.app/Contents

Step 3 was important, without it flutter doctor --android-licenses would always fail...

2
  • Maybe not fully related here, as question title states M1 processor, but I still think it might be helpful to some.
    – ldlgds
    Commented Jan 29, 2023 at 16:21
  • this solution worked for me on my M2 Mac Mini Commented Feb 3, 2023 at 21:16
8

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:

enter image description here

3
  • 1
    this steps are working for me
    – rNkL
    Commented May 2, 2023 at 11:07
  • In case you face "ln: jre: Operation not permitted", simply allow Full disk access to iTerm. See osxdaily.com/2018/10/09/…
    – jaletechs
    Commented Mar 20, 2024 at 8:59
  • thanks! it works for me! Commented Dec 7, 2024 at 17:44
6

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.

  1. cd /Applications/Android\ Studio.app/Contents/jre

  2. ln -s ../jre jdk

  3. ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk

  4. flutter doctor -v

Now, you should be able to see the error is disappeared in flutter doctor description in terminal.

4

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:

  1. cd /Applications/Android\ Studio.app/Contents/jre

  2. ln -s ../jre jdk

  3. ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk

  4. Flutter Doctor

4

This solution is for M1 Mac User

  1. Find your local Java version by typing /usr/libexec/java_home -V. If didn't exist, install the latest ARM Java version here
  2. 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
  3. 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
  1. Finally run flutter doctor -v to see all the details changes
2
  • 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 said permission denied /Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home. Is there somewhere else I should type? How do I give it permission?
    – Sam
    Commented 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 chown sudo 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.
    – Alphapico
    Commented Jan 15, 2023 at 7:21
2

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

2

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

1

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
0

COPY folder /Applications/Android Studio Preview.app/Contents/jre/Contents to /Applications/Android Studio Preview.app/Contents/jre/jdk/Contents

2
  • This workaround might violates standard AS default JAVA_HOME directory, have you already tried in your local?
    – mochadwi
    Commented Jul 29, 2021 at 3:14
  • 1
    You 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"
    – crzorz
    Commented Jul 29, 2021 at 3:19
0

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.

1
  • This is not an answer. You must comment such things! Commented Jan 18, 2023 at 4:14
0

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.

0

Copying all contents of JDK and pasting it into a JRE file, worked for me.

After that, I updated my ENV path.

-1

Here is the simple solution for this issue: Java issue on Mac

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.