Unable to find bundled Java version on Flutter

Are you experiencing issues with finding the bundled Java version on Flutter? If so, don’t worry! This post will guide you through the solutions to this problem.

For Mac Users:

To resolve the issue of being unable to find the bundled Java version on Flutter for Mac users, follow these steps:

  1. Set the JAVA_HOME path by following this article. Then apply the following commands:
  2. cd /Applications/Android\ Studio.app/Contents/jbr
    ln -s ../jbr jdk
    ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
    
  3. Go to Finder and search for Android Studio. Right-click on it, then click Show Package Contents.
  4. Open the contents folder, then create a new folder called jre. Copy the contents of the JetBrains Runtime folder and paste them into the jre folder.
  5. Type in Terminal: flutter doctor -v

This should resolve the issue for Mac users using the JetBrains Runtime “Android Studio Electric Eel”. If you are still facing issues, see below.

Other Versions:

If you’re not using the latest version of Android Studio and Flutter, or if you’re experiencing issues with other versions, try these commands instead:

  1. Type in Terminal: cd /Applications/Android\ Studio.app/Contents/jre
  2. Type in Terminal: ln -s ../jre jdk
  3. Type in Terminal: ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
  4. Type in Terminal: flutter doctor -v

For Mac Users who are using the JetBrains Toolbox:

To resolve the issue of being unable to find the bundled Java version on Flutter for Mac users using the JetBrains Toolbox, follow these steps:

  1. Set the JAVA_HOME path by following this article.
  2. Change your username to your macOS username and run: cd /Users/username/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7583922/Android Studio.app/Contents/jre
  3. Type in Terminal: ln -s ../jre jdk
  4. Type in Terminal: ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
  5. Type in Terminal: flutter doctor -v

Workaround:

If you’re still facing the issue, try this workaround:

  1. Type in Terminal: cd /Applications/Android\ Studio.app/Contents
  2. Type in Terminal: ln -s jbr jre

The Right Approach:

In short and simple, the best approach to fix this issue is by upgrading your Android Studio and Flutter to the latest versions, in order to avoid any potential issues (e.g. patching) in future.

Original Answer:

For those having these issues with the latest Android Studio – Electric Eel version, and other canaries and preview releases, note that the bundled jre directory in the Android Studio installation folder is now renamed to jbr

To resolve this, just create a sym link jre -> jbr and Flutter won’t complain. Here are the commands for different operating systems:

On Linux

  1. Type in Terminal: cd ~/android-studio/ && ln -s jbr jre

Windows (check installation folder)

Type in Terminal:

cd C:\Program Files\Android\Android Studio
mklink /D "jre" "jbr"

or

New-Item -ItemType SymbolicLink -Path .\jre -Target .\jbr

Mac OS

  1. Type in Terminal: cd /Applications/Android\ Studio.app/Contents
  2. Type in Terminal: ln -s jbr jre

Note that if you are running a preview release, and depending on your OS, the default installation directory might be different, e.g. on Linux it would be ~/android-studio-preview/

Conclusion:

In conclusion, to resolve the issue of being unable to find the bundled Java version on Flutter, you can try the solutions provided in this post. If none of them work for you, consider upgrading your Android Studio and Flutter to the latest versions.