1

I get this error when I try to run "flutter doctor --android-licenses" and I can't figure out why.

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 R
untime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:650)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:632)
Android sdkmanager tool was found, but failed to run (C:\\Users\\Gago\\AppData\\Local\\Android\\sdk\\cmdline-tools\\latest\\bin\\sdkmanager.bat): "exited code 1".
Try re-installing or updating your Android SDK,
visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.

Here's my flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
\[√\] Flutter (Channel stable, 3.7.7, on Microsoft Windows \[Version 10.0.19044.2604\], locale de-DE)
\[X\] Windows Version (Unable to confirm if installed Windows version is 10 or greater)
\[!\] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
\[√\] Chrome - develop for the web
\[√\] Android Studio (version 2022.1)
\[√\] IntelliJ IDEA Community Edition (version 2021.2)
\[√\] IntelliJ IDEA Ultimate Edition (version 2022.2)
\[√\] VS Code (version 1.75.1)
\[√\] Connected device (2 available)
\[√\] HTTP Host Availability

! Doctor found issues in 2 categories.

Any help is appreciated!

I already tried deinstalling Android Sdk Command line tool and reinstalling it, but it doesnt help. I am using Android Studio and my jdk is JDK 1.8.0_301.

gag0
  • 89
  • 1
  • 7

6 Answers6

5

I fixed the issue. What worked for me was this:

  1. Uncheck Android SDK command-line Tools (latest)
  2. Check Android SDK command-line Tools 8.0
  3. Click Apply
  4. In Windows, go to “C:\Users\USERNAME\AppData\Local\Android\Sdk\cmdline-tools” and rename the 8.0 folder to “latest”
  5. Run Flutter doctor again.

This is a solution by @thurakhant on github. Thank you!

gag0
  • 89
  • 1
  • 7
2

Having the exact same JDK and flutter version I had this problem yesterday (in Macbook). The solution was to access the Android studio folder:

/Applications/Android Studio.app/Contents

And have the two "jbr" and "jre" folders there, being "jre" a mere copy of "jbr"

flutter doctor -v command reported "No issues found!" with this change.

the last bit
  • 21
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 17 '23 at 15:54
2

First check "Show package details" and select version Android SDK command-line Tools 8.0

0

Check if your gradle version is at least 7.6

android : gradle : wrapper : gradle.properties

gradle-7.6-all.zip
Hooman
  • 753
  • 5
  • 13
0
  1. Open Android Studio and Click on SDK Manager.
  2. Click on SDK tools, then select Show Package Details and navigate to Android SDK command-line tools, select version 8.0, and hit apply button.
  3. Set the Environment variable of JAVA_HOME to C:\Program Files\Android\Android Studio\jbr
  4. Now Run the command:

flutter doctor --android-licenses

vikas
  • 295
  • 4
  • 16
0

Download the latest java sdk. Then go the environment variables. Inside the User variables for User, add two variables.

  1. JAVA_HOME => C:\Program Files\Java\jdk-20 (Paste your sdk path)
  2. JDK_HOME => C:\Program Files\Java\jdk-20 (Paste your sdk path)

Add the above two variables. My problem was solved this way.