Right approach
In short and simple, the best approach to fix this issue is by upgrading your Android Studio and Flutter to 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.
On Linux
cd ~/android-studio/ && ln -s jbr jre
Windows (check installation folder)
cd C:\Program Files\Android\Android Studio
mklink /D "jre" "jbr"
or
New-Item -ItemType SymbolicLink -Path .\jre -Target .\jbr
Mac OS
cd /Applications/Android\ Studio.app/Contents
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/
In either case, you can check the installation directory by running
flutter doctor -v
Also, in case if you run with permissions issues, you can try running the command with admin privileges, depending on your OS.
For example on Mac/Linux, you can just run the same command with sudo
and it should work, additionally on Mac, you’ll have to configure the Disk Access permissions, depends on your version, but most probably can be found under:
Settings - Privacy & Security - Full Disk Access - Terminal
baranhuseyinkencu@BARAN-MacBook-Air ~ % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.5, on macOS 13.2.1 22D68 darwin-arm64, locale tr-TR)
[✓] Android toolchain — develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode — develop for iOS and macOS (Xcode 14.2)
[✓] Chrome — develop for the web
[!] Android Studio (version 2022.1)
✗ Unable to find bundled Java version.
[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
[✓] VS Code (version 1.75.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
! Doctor found issues in 1 category.
baranhuseyinkencu@BARAN-MacBook-Air ~ % flutter doctor -v
[✓] Flutter (Channel stable, 3.7.5, on macOS 13.2.1 22D68 darwin-arm64, locale tr-TR)
• Flutter version 3.7.5 on channel stable at /Users/baranhuseyinkencu/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c07f788 (2 days ago), 2023-02-22 17:52:33 -0600
• Engine revision 0f359063c4
• Dart version 2.19.2
• DevTools version 2.20.1
[✓] Android toolchain — develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /Users/baranhuseyinkencu/Library/Android/sdk
• Platform android-33-ext4, build-tools 33.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.
[✓] Xcode — develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.11.3
[✓] Chrome — develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.1)
• 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.15+0-b2043.56-8887301)
[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• 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
[✓] VS Code (version 1.75.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.58.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.2.1 22D68 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 110.0.5481.100
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
baranhuseyinkencu@BARAN-MacBook-Air ~ % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.5, on macOS 13.2.1 22D68 darwin-arm64, locale tr-TR)
[✓] Android toolchain — develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode — develop for iOS and macOS (Xcode 14.2)
[✓] Chrome — develop for the web
[✓] Android Studio (version 2022.1)
[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
[✓] VS Code (version 1.75.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
• No issues found
why do i have «Intellij idea» inside the list.
Problem:
Cause: If you run “flutter doctor” on your terminal and you see something similar to the screenshot below, Java cannot be found on your system and is the cause of this error.
1. To fix this kind of Error you must check first the java and jdk version. If you have already installed java in your pc or laptop. Run this command java -version and echo %JAVA_HOME% on command prompt.
Command: echo %JAVA_HOME%
If the version shows in the command for java and jdk in your pc or laptop is the same proceed to the step 2.
2. Check the System Environment Variables
- To Access the Environment Variables, use search bar on the windows and search System Environment Variable
- Click the Edit System Environment Variables after that click the button Environment Variables..
- Click JAVA_HOME Enviroment Variable on system environment.
Check if the jdk version on your pc or laptop is the same on the JAVA_HOME Environment Variables. Now if it is still the same click the Path on the System Variables.
How about if you have not already set the Environment Variable JAVA_HOME in your pc or laptop. You can learn how to set up this environment variables on https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html
Even the system JAVA_HOME Environment Variable of your is the same with the jdk version on your system and still not detected you must try the step 3.
3. Goes to Local Disk C and browse the Program Files and follow this following steps:
- 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”.
- When you are already at the Android Studio installation root folder, you will see two folders: “jbr” and “jre“.
- Copy all the files inside the “jbr” folder to the “jre” folder, then try it again.
Paste the files from jbr in jre
Run again the flutter doctor command
Issue
I am using Android Studio under Windows 10 to make run a flutter project, however I have this warning I would like to fix :
X Unable to determine bundled Java version.
• Try updating or re-installing Android Studio.
I have already try multiple solutions exposed on Stackoverflow / Git but no ones worked.
Here the settings of my project :
Here my flutter doctor :
C:\lib\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [version 10.0.19042.1165], locale fr-FR)
• Flutter version 2.2.3 at C:\lib\flutter
• Framework revision f4abaa0735 (8 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:/Users/[MY_USER]/AppData/Local/Android/Sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = C:/Users/[MY_USER]/AppData/Local/Android/Sdk
• Java binary at: C:\Program Files\Java\jdk1.8.0_291\bin\java
• Java version Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[!] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
• 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
X Unable to determine bundled Java version.
• Try updating or re-installing Android Studio.
[√] VS Code (version 1.59.1)
• VS Code at C:\Users\[MY_USER]\AppData\Local\Programs\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (3 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.159
• Edge (web) • edge • web-javascript • Microsoft Edge 92.0.902.84
! Doctor found issues in 1 category.
Process finished with exit code 0
Could you provide help please ?
Solution
So here the action I have done:
Install latest version of jdk: https://www.oracle.com/java/technologies/javase-downloads.html
Install latest version of jre: https://www.oracle.com/java/technologies/javase-jre8-downloads.html
Go to: C:\Program Files\Android and remove all version of Android Studio
Go to Windows search: Environement Variables > Environement Variables > System Variables and add JAVA_HOME with value the path to your jdk (C:\Program Files\Java\jdk-16.0.2)
Install Android Studio again
Go to file > Project Structure
Put your JDK path:
Go to file > Settings
Click on Show Package Details and retrograde to 20.1 or 22.2 (not sur for 22.2 but read that for some it works)
Verify you’re on a stable version:
flutter pub get
flutter pub upgrade
flutter pub outdated
flutter doctor -v
and it should be good: • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
Answered By — Da2ny
Introduction
Flutter is a popular framework for developing cross-platform mobile applications. It provides a rich set of features and libraries that simplify the app development process. However, when working with Flutter, it’s essential to understand and manage the bundled Java version. This guide will help you troubleshoot and locate the bundled Java version in your Flutter environment.
What is a Bundled Java Version in Flutter?
Before diving into troubleshooting, let’s understand what a bundled Java version means in the context of Flutter. When you install Flutter, it includes a pre-packaged Java Development Kit (JDK) that is required for Android app development. This bundled JDK ensures that Flutter apps can be compiled and run on Android devices seamlessly.
Why is it Important to Find the Bundled Java Version?
Finding the bundled Java version is crucial for various reasons. Firstly, knowing the specific JDK version used by Flutter helps ensure compatibility with the Android platform and related libraries. Secondly, troubleshooting certain issues in Flutter projects often requires knowledge of the underlying JDK version. Therefore, locating the bundled Java version is a fundamental step for maintaining a stable and productive development environment.
Troubleshooting: Unable to Locate the Bundled Java Version
If you’re unable to find the bundled Java version in your Flutter setup, don’t worry. Follow these troubleshooting steps to identify the Java version:
a) Checking the Flutter SDK Installation
- Ensure that you have the latest Flutter SDK installed on your system.
- Open a terminal or command prompt and run the following command:
This command provides information about your Flutter installation, including the bundled Java version.
b) Verifying the System Path Environment Variable
- Check if the system Path environment variable is properly configured to include the Flutter SDK location.
- Open a terminal or command prompt and run the following command:
Ensure that the Flutter SDK path is included in the output.
c) Inspecting Flutter Project Configuration
- Open your Flutter project in a code editor.
- Look for the
android
folder and navigate to theapp
directory. - Inside the
app
directory, locate thebuild.gradle
file. - Open the
build.gradle
file and search for thecompileOptions
section. - Within
compileOptions
, you’ll find thesourceCompatibility
andtargetCompatibility
settings. These indicate the Java version used by the project.
d) Exploring Platform-Specific Requirements
- Flutter projects often have platform-specific requirements, such as additional Java dependencies or configuration files.
- Consult the official Flutter documentation or relevant resources specific to your project’s target platform (e.g., Android) for any specific instructions on locating the bundled Java version.
Alternative Methods to Identify the Bundled Java Version
If the troubleshooting steps mentioned above do not yield the desired results, you can try alternative methods to identify the bundled Java version in Flutter:
a) Using Flutter Doctor Command
- Open a terminal or command prompt.
- Run the following command:
This command provides detailed information about your Flutter installation, including the bundled Java version.
b) Checking the Flutter SDK Release Notes
- Visit the Flutter SDK release notes on the official Flutter website.
- Look for the release notes related to your installed version of Flutter.
- Check if any specific information regarding the bundled Java version is mentioned.
c) Reviewing the Flutter Project Files
- Go through the project files in your Flutter project, such as
pubspec.yaml
,android/gradle.properties
, or any other relevant files. - Look for any references to the Java version or related configuration that might indicate the bundled Java version.
Best Practices for Managing Flutter’s Bundled Java Version
To ensure a smooth development experience with Flutter, consider the following best practices for managing the bundled Java version:
a) Keeping the Flutter SDK Updated
Regularly update your Flutter SDK to the latest stable version. This ensures that you have access to the most recent improvements, bug fixes, and bundled Java version updates.
b) Handling Java Version Conflicts
If you work on multiple projects with different Java version requirements, you may encounter version conflicts. In such cases, use version managers like Jabba, SDKMAN, or similar tools to switch between Java versions conveniently.
c) Utilizing Version Managers
Consider utilizing version managers not only for managing Java versions but also for Flutter SDK and related tools. Version managers simplify the process of switching between different versions, making it easier to handle projects with specific requirements.
Conclusion
Locating the bundled Java version in your Flutter development environment is essential for maintaining compatibility and troubleshooting issues. By following the troubleshooting steps and alternative methods outlined in this guide, you can easily identify the bundled Java version and ensure a smooth Flutter app development experience.
FAQs (Frequently Asked Questions)
- Q: How do I update the Flutter SDK to the latest version?
- A: To update the Flutter SDK, open a terminal or command prompt and run the following command:
flutter upgrade
. This command updates your Flutter installation to the latest stable version.
- A: To update the Flutter SDK, open a terminal or command prompt and run the following command:
- Q: Can I use a different Java version than the bundled one in Flutter?
- A: While it’s recommended to use the bundled Java version for Flutter, you can configure your Flutter project to use a different Java version if needed. However, this may require additional configuration and might introduce compatibility issues.