115

I have Android Studio version 3.0
When I use the command flutter doctor it shows me the following,

Unable to find bundled Java version

My current Java version is (build 1.8.0_131-b11)

Abhimanyu
  • 5,260
  • 2
  • 25
  • 64
shariful hasnine
  • 1,145
  • 2
  • 7
  • 6

19 Answers19

290

For Mac User

Set Java_Home path using below article & then after applying below command

https://mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/#what-is-usrlibexecjava-home

after that type below command on terminal

cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
flutter doctor -v

Edit #1:

For Mac users who are using JetBrains Toolbox, here is the solution:

Set Java_Home path using below article & then after applying below command

https://mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/#what-is-usrlibexecjava-home

after that type below command on terminal

change username to your macOS username

cd /Users/username/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7583922/Android Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
flutter doctor -v
Ambitions
  • 1,980
  • 3
  • 11
  • 22
Nalawala Murtuza
  • 3,393
  • 1
  • 10
  • 18
  • 25
    Solve perfect after update to Android Studio Arctic Fox 2020.3.1 – Álvaro Menezes Jul 29 '21 at 20:11
  • 2
    Worked with me after updating to Android Studio Arctic Fox 2020.3.1 on July 30th. Thanks – M. A. Jul 30 '21 at 12:31
  • just add a bit info. from that mkyong.com article, you only need to execute the command from 2.1 2.2 and 2.3 then continue to execute the command from Nalawala above. it works! – Alexa289 Jul 31 '21 at 02:23
  • 4
    I am using `JetBrains Toolbox` which installs Android Studio on a different directory which is `/Users/username/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7583922/Android Studio.app`. I will edit your great answer to ensure that it supports all of macOS users. Your solution is great. – Ambitions Jul 31 '21 at 15:07
  • @NalawalaMurtuza You are more than welcome. Please approve my edit. – Ambitions Jul 31 '21 at 18:30
  • 2
    Thank you. This solved my problem with Android Studio (arctic fox 2020.3.1 - July 26, 2021 built). @Ambitions, thank you for the path. – Cetin Basoz Jul 31 '21 at 23:24
  • Fantastic. Works perfect for me. Thanks. – CNK Aug 01 '21 at 23:17
  • I'm almost try all possible solution but nothing work. Only this one work for me. Its from `August 9, 2021` Check the link for the solution https://stackoverflow.com/a/68703869/8555332 – Tahmid Bin Rashid Aug 08 '21 at 20:02
  • Thanks very much. After searching for solution this was the only perfect one. – CNK Aug 10 '21 at 11:36
  • also work for me. just note. JRE folder you can find at cd /Applications/Android\ Studio.app/Contents/jre – Indra As Lesmana Aug 16 '21 at 04:10
  • cd /Applications/Android\ Studio.app/Contents/jre ln -s ../jre jdk ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk flutter doctor -v – Indra As Lesmana Aug 16 '21 at 04:11
  • Thank you! It worked - but I had to look for the latest version: $ ls -1 ~/Library/Application\ Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0 203.7583922 203.7621141 $ cd ~/Library/Application\ Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7621141/Android\ Studio.app/Contents/jre $ ln -s ../jre jdk $ flutter doctor -v ...snip... • No issues found! – Dietrich Bollmann Aug 19 '21 at 11:20
  • 1
    broke for me after upgrading to arctic fox. Why can they not simply fix this? Why, after every update, do we need to jump in and fix the mess they make? – Chris Hardaker Aug 22 '21 at 13:54
  • After many tries, this was what solved. Thanks – Thiago Silva Aug 29 '21 at 23:27
  • this is the ideal answer, thanks for the person how wrote this post, and also the path article. – M.Nasri Nov 18 '21 at 18:54
  • creating sym-links (as suggested in this answer) will break it once again when you update Android Studio. Better just follow steps 3 + 4 in the linked article from mkyong.com – bbjay Dec 07 '21 at 17:17
  • Worked perfectly on Android Studio Preview, with slight change to command to account for beta version "cd /Applications/Android\ Studio\ Preview.app/Contents/jre" – Mijawel Dec 23 '21 at 23:24
28

For Windows: If you are using windows go to this directory C:\Program Files\Android\Android Studio and check older Android Studio folders are exist if exist delete those. it will work.

BabaVarma
  • 356
  • 3
  • 7
  • 2
    yes worked for the arctic fox upgrade. The old folder had only the JRE folder, LOL. Thanks man. Please highlight FOR Windows in your answer. – Neail Sep 30 '21 at 08:30
  • 1
    Thanks! After deleting older installation, it worked. – Isuru Jan 23 '22 at 23:24
25

In my case, am using macOS, there was a copy of Android Studio Preview in my downloads folder. I just deleted that Android Studi Preview file and the error gone :)

16

Those on the Beta Versions of MAC OS Beta, Xcode Beta, Android Studio Preview.

Just ensure your path ways are correct to the Applications files for Flutter.

To fix JAVA Bundle for Android Studio Preview do this:

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

ln -s ../jre jdk

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

flutter doctor -v
Bonny James
  • 321
  • 1
  • 4
5

Double check the path, solved my problem wrapping the path with quotation marks...

Before:

enter image description here

After:

enter image description here

Andre Sampaio
  • 334
  • 3
  • 6
4

Apple Silicon Users Problem Solved!

First do this: Flutter Doctor --android-licenses : Exception in thread "main" java.lang.NoClassDefFoundError

Then:

  1. Make Sure to set Java_Home path in .zshrc using same article already listed here. He explains using the .zshenv but we will edit .zshrc file.

https://mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/#what-is-usrlibexecjava-home

  1. Uninstall Java from your system
  2. Re-install the M1 Specific Version from Azul. Choose Java 16. Choose ARM 64 bit https://www.azul.com/downloads/?package=jdk

Here's Where I Was Stuck But Finally Found The Fix

Run these commands:

  1. cd /Applications/Android\ Studio.app/Contents/jre
  2. ln -s /Library/Java/JavaVirtualMachines/zulu-16.jdk jdk
  3. flutter doctor -v
4

if you are using Windows and install a new version of android, please check older Android Studio folders are exist or not in C:\Program Files\Android\Android Studio. if exist delete those. The errors will be gone!

Md omer arafat
  • 328
  • 4
  • 11
4

I have recently encountered the same issue on Ubuntu 20.04 LTS.

After searching a lot I have fixed this issue by removing the Android Studio path from the Flutter config by running below mention command.

flutter config --android-studio-dir=   

Solution:

Solution

m4n0
  • 27,411
  • 26
  • 71
  • 84
Zain
  • 41
  • 3
4

I was getting error as below,

enter image description here

Execute below steps to resolve this issue,

  1. Visit Google folder in user directory enter image description here
  2. Delete the AndroidStudio4.1 directory ( For which I was getting error ) enter image description here

Run "flutter doctor" again. My problem was fixed

3

Had this issue of ✗ Unable to find bundled Java version. Seems like the issue was with Android Studio (Beta Version)

Changed my Android Studio (Stable Version) to solve the issue

Here are the flutter doctor -v details for each Android Studio

Beta Android Studio

[!] Android Studio
    • Android Studio at /Applications/Android Studio Preview.app/Contents
    • 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
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

Stable Android Studio

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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.8+10-b944.6916264)

Even after this issue persist then

  • Check for Java java -version which java

  • double-check that these are present in your .bashrc or .bash_profile or .zshrc

export PATH="$PATH:/usr/bin/java"
export JAVA_HOME=$(/usr/libexec/java_home)
samridhgupta
  • 1,539
  • 1
  • 16
  • 31
1

I get this error this morning, when updated ANDROID STUDIO to new version, so to solve this problem you need to find previous version from https://developer.android.com/studio/archive and setup, it works for me! (sorry, if exists grammatical errors)

1

I use macos big sur 11.5.1 also have the above situation and have successfully fixed the error: Unable to find bundled Java version on Flutter && ! Some Android licenses are not accepted. To resolve this, run: flutter doctor --android-licenses CH-0 / 203.7678000 is the version you installed if you have to fix it

cd ~/Library/Application\ Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7678000/Android\ Studio.app/Contents/jre

sudo ln -s ../jre jdk

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

flutter doctor --android-licenses

flutter doctor -v`

0

Please ensure Java is in your PATH and that JAVA_HOME is defined and pointing to the JDK. I've had Windows put the JRE in the path instead of the JDK, which leads to all kinds of issues.

Please take a look at your PATH environment variable and remove everything Java related that does not point to the JDK folder.

Oracle has some documentation on how to do this here : Installing Java and setting JAVA_HOME

Ewald
  • 5,533
  • 1
  • 27
  • 29
0

The JAVA_HOME path, as stated in mkyong link by @Nalawala answer, must refer to a Java 1.8 JDK/JRE.

With Java 11 the flutter doctor --android-licenses command throws some ClassNotFoundException's

0

Uninstall Android Studio...

Delete folder $/Program Files/Android

Install Android studio...

$flutter doctor

Yogesh Alai
  • 150
  • 1
  • 5
0

In my case, there were two "Android Studio" folders. One was "Android Studio" and another was "Android Studio1", the "Android Studio1" had the actual app installed and the "Android Studio" folder was empty. Deleting the empty folder and renaming the "Android Studio1" to "Android Studio" fixed the issue.

Abhi R
  • 102
  • 3
-1

In my case, I recently bought an M1 Macbook and then installed Android Studio with the Jetbrains Toolbox but

This folder doesn't exist

/Users/username/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7583922/Android Studio.app/Contents/jre

So I follow what this comment say and now is working just fine https://github.com/flutter/flutter/issues/76215#issuecomment-893512809

1.- Go to Applications folder then right click on your android studio app 2.- click on Show package contents 3.- open a terminal inside jre folder then create the new jdk folder

mkdir jdk

4.- move the folder Contents into jdk

mv Contents jdk

After refreshing my terminal, flutter doctor works just fine!

  • This will probably break other stuff. Also, it stops working when you update Android Studio – bbjay Dec 07 '21 at 17:15
-2

1.Write the path in quotes i.e flutter config --android-studio-dir "C:\Program Files\Android\Android Studio".

2.Please check the correct path of android Studio.

3.Do the 1st step and run flutter doctor .

-6

enter image description here

I was getting this error when I run flutter doctor.

Solution:

  • Go to the file "java" following the path where Error is shown.
  • Then right click on the file and go to Properties.
  • Then Go to permissions and Check the box "Allow executing file as program".
  • Finally, run flutter doctor to see No issues found!.