Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter doctor --android-licenses not working due to java.lang.UnsupportedClassVersionError

I am trying to accept flutter doctor --android-licenses but I am getting this error:

Error: A JNI error has occurred, please check your installation and try again
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
like image 742
Ajay Jha Avatar asked Dec 11 '25 09:12

Ajay Jha


2 Answers

I'm on MacOS Ventura. I installed Android Studio today. This is how I solved the problem:

  1. Downloaded JDK19
  2. Followed the steps mentioned at this link
  3. Since I'm running Android Studio Electric Eel, opened Terminal and ran this command cd /Applications/Android\ Studio.app/Contents/jbr
  4. Then ran this command after ln -s ../jbr jdk
  5. And finally, ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
  6. Went to Finder -> Applications -> Android Studio. Right-click Android Studio and select 'Show Package Contents'
  7. Created new folder 'jre' in folder 'Contents'
  8. Copied contents from the 'jbr' folder to the 'jre' folder
  9. Ran flutter doctor again
  10. Ran flutter doctor --android-licenses.

I was able to agree to the licenses successfully after.

All the steps are also mentioned here and here

like image 193
AyeshaA Avatar answered Dec 14 '25 04:12

AyeshaA


I've had the same error, I haven't specify JAVA_HOME env, and flutter used my 1.8 java.

For macOS: Check your JAVA_HOME env in terminal with

printenv

if env not existed, list installed java version

/usr/libexec/java_home -V

choose one and execute

export JAVA_HOME=$(/usr/libexec/java_home -v"YOUR_VERSION")
like image 35
marc_ Avatar answered Dec 14 '25 05:12

marc_