skip to Main Content

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

7

Answers


  1. UPDATE

    It turns out there are 2 JDK installed in my environment, you can check by using

    /usr/libexec/java_home -V
    

    so after removing the older JDK version, the issue is fixed.


    Having the same error, although here is my java --version output

    java 19.0.1 2022-10-18
    Java(TM) SE Runtime Environment (build 19.0.1+10-21)
    Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
    

    this happens after I upgrade to flutter 3.7.1

    Login or Signup to reply.
  2. 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")
    
    Login or Signup to reply.
  3. You can run the following command to see if you have multiple java versions:

    /usr/libexec/java_home -V
    

    In my case, I had 2 versions on my mac: java 8 and java 19. I followed the official java website to remove my older version:

    sudo rm -fr /Library/Internet Plug-Ins/JavaAppletPlugin.plugin
    
    Login or Signup to reply.
  4. 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

    Login or Signup to reply.
  5. Try This (For Windows)

    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:UsersUSERNAMEAppDataLocalAndroidSdkcmdline-tools”
      and rename the 8.0 folder to “latest”
    5. Run Flutter doctor again.
    Login or Signup to reply.
  6. There is a simple way to resolve this issue.

    • Check java version you installed on your machine. If it is version 8, Installed Android SDK Command-line Tools 8.0 & uninstalled latest version.
      enter image description here
    Login or Signup to reply.
  7. The problem seems to be when the android studio installed is Android Studio Electric Eel

    All you have to do is:

    1. Follow this link and ddownload – install this jdk https://www.oracle.com/java/technologies/downloads/#jdk19-mac
    2. After installing, goto Finder -> Applications -> Android Studio. Right-click on Android Studio and select ‘Show Package Contents’
    3. Open the Contents folder and create new folder and name it jre
    4. There’s a folder named jbr open it and copy the folder inside it and paste it into your newly created folder on step 3 (jre).
    5. You can now be able to accept the licences by running- flutter doctor –android-licences
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search