2

I'm trying to install Flutter and can't seem to get through the part of accepting the Android licenses in flutter doctor. I keep getting this error when I try to run 'flutter doctor --android-licenses' in the command prompt.

C:\Users\anach>flutter doctor --android-licenses
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
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
        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:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        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:544)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" Android sdkmanager tool was found, but failed to run (C:\Users\anach\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.

I've tried almost every solution including manually downloading the Android SDK Tools in Android Studio's SDK Manager but I still get the same error. I've read that people are experiencing the same problems when updating to Android Studio Electric Eel. Does anyone know how to resolve this?

Nashuha Kamal
  • 21
  • 1
  • 2
  • The error message says, `AndroidLocationsProvider has been compiled by a more recent version of the Java Runtime`. I think you may need to update Java on your computer. – 7stud Mar 17 '23 at 04:05

3 Answers3

0

Have you checked if you have the Android SDK Command-Line Tools installed, you can check it in Android Studio under Appearance and Behavior > System Settings > Android SDK.

Android Studio

  • Yup I already have it installed. I've also re-installed Android Studio but the same error still show up – Nashuha Kamal Mar 17 '23 at 03:50
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 23 '23 at 07:48
0

Put this licenses folder in your Android SDK root License folder and then restart your IDE

Vikas
  • 432
  • 4
  • 17
0

Download and install latest JDK (For me now is 20) and Update environment variables.
JAVA_HOME = C:\Program Files\Java\jdk-20
JDK_HOME = C:\Program Files\Java\jdk-20

good luck

peyman
  • 121
  • 4