Unable to find bundled Java version with flutter doctor, after updating Android studio Arctic Fox(2020.3.1) on M1 Apple Silicon
AndroidFlutterApple M1Apple SiliconAndroid 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.
-
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
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.
-
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.
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:
-
cd /Applications/Android\ Studio.app/Contents/jre
-
ln -s ../jre jdk
-
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
-
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
- 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
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