System Settings:
-
MacOS Ventura
-
Android Studio Electric Eel
I am installing Flutter on my Intel Mac.
After Running flutter doctor
The outcome is this:
[✓] Flutter (Channel stable, 3.7.0, on macOS 13.2 22D49 darwin-x64, locale
en-MX)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for
more details.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.74.3)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
and after running flutter doctor --android-licenses
the outcome is this:
Exception in thread "main" java.lang.UnsupportedClassVersionError:
com/android/prefs/AndroidLocationsProvider
has been compiled by a more recent version of the Java Runtime (class file version 55.0),
this version of the Java Runtime only recognizes class file versions up to 52.0
I installed Java for Mac from this link on January 2023 from Here
Has someone encountered the same error? How did you fix it?
9
Answers
Found the solution.
I needed to update the JDK from here.
I have uninstalled. JRE Java runtime environment and it works.
I will try to give a more detailed solution:
x64 DMG Installer
(this worked for me)JAVA_HOME
path following these instructions (mac)flutter doctor --android-licenses
Additionally from what Tomas Ward said about installing the lastest SDK, for windows I found this for adding the JAVA_HOME to the path. Hope it helps.
Yeah @Tomas Ward solution is worked For me. But Let me add some more details For the Windows users.
19.0.2 First of all Click On This Link To Download Java SE Development Kit 19.0.2.
Install Java SE Development Kit In Your System.
JAVA_HOME Path.
And As You Set/Update JAVA_HOME Path Your Error will resolved.
For Windows
Download and Install latest JDK from [Java SE Development Kit 19.0.2][1]
Set a system variable as
Variable Name: JAVA_HOME
Variable Value: C:Program FilesJavajdk-19
Add a path variable name as
%JAVA_HOME%bin
Now run
flutter doctor
Hope, it will solve.
[1]: https://www.oracle.com/java/technologies/downloads/#jdk19-windows
While installing the JDK by Oracle download works, best way to make sure that you have the correct version on MacOS is to install JDK using Homebrew (If you don’t have Homebrew, Installation instructions: https://docs.brew.sh/Installation). Also, keeping it up-to-date is a lot easier this way.
If you have other OpenJDK versions installed, you may need to link this correct one:
To make it the default for your shell, add the following lines to ~/.zshrc:
And then:
You only need to do this once.
Then rerun:
flutter doctor --android-licenses
I tested a higher version (jdk17) and successfully executed it. But I don’t think this is a good idea. Let’s wait for the official solution
None of these answers worked for me. So I finally bit the bullet and switched over to asdf. It’s worth it and will save you so much trouble in the future.
asdf install java adoptopenjdk-19.0.0+36
asdf global java adoptopenjdk-19.0.0+36
exec zsh
# reloads current terminal to use changed .zshrcecho $JAVA_HOME
should show asdf directory oneflutter doctor --android-licenses
Machine details