Unable to find bundled Java version with flutter doctor, after updating Android studio Arctic Fox(2020.3.1) on M1 Apple Silicon

AndroidFlutterApple M1Apple Silicon

Android Problem Overview


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?

Android Solutions


Solution 1 - Android

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

Solution 2 - Android

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

Solution 3 - Android

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.

Solution 4 - Android

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

Solution 5 - Android

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

Solution 6 - Android

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

Solution 7 - Android

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

Solution 8 - Android

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

Solution 9 - Android

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMohamad FarisView Question on Stackoverflow
Solution 1 - AndroidMiktadView Answer on Stackoverflow
Solution 2 - AndroidSuragchView Answer on Stackoverflow
Solution 3 - AndroidMir MumtazView Answer on Stackoverflow
Solution 4 - AndroidKaushik GodhaniView Answer on Stackoverflow
Solution 5 - AndroidFilip BjelobabaView Answer on Stackoverflow
Solution 6 - AndroidX ShamView Answer on Stackoverflow
Solution 7 - AndroidDieterView Answer on Stackoverflow
Solution 8 - AndroidcrzorzView Answer on Stackoverflow
Solution 9 - AndroidStephen NyamweyaView Answer on Stackoverflow