skip to Main Content

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


  1. Chosen as BEST ANSWER

    Found the solution.

    I needed to update the JDK from here.


  2. I have uninstalled. JRE Java runtime environment and it works.

    Login or Signup to reply.
  3. I will try to give a more detailed solution:

    1. Install the latest version of the Java SDK from this link
    2. Pick Java 19 and the x64 DMG Installer (this worked for me)
    3. Follow the installation instructions.
    4. [optional] If necessary, set your JAVA_HOME path following these instructions (mac)
    5. Test the installation by running flutter doctor --android-licenses
    Login or Signup to reply.
  4. 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.

    Login or Signup to reply.
  5. Yeah @Tomas Ward solution is worked For me. But Let me add some more details For the Windows users.

    1. As @Tomas says We need to download Java SE Development Kit
      19.0.2
      First of all Click On This Link To Download Java SE Development Kit 19.0.2.
    2. Then Download x64 Installer OR x64 MSI Installer Then
      Install Java SE Development Kit In Your System.
    3. Now You need to Set OR Update This New Java SE Development Kit Path into Your
      JAVA_HOME Path.

    And As You Set/Update JAVA_HOME Path Your Error will resolved.

    Login or Signup to reply.
  6. For Windows

    1. Download and Install latest JDK from [Java SE Development Kit 19.0.2][1]

    2. Set a system variable as

      Variable Name: JAVA_HOME

      Variable Value: C:Program FilesJavajdk-19

    3. Add a path variable name as %JAVA_HOME%bin

    4. Now run flutter doctor

    Hope, it will solve.
    [1]: https://www.oracle.com/java/technologies/downloads/#jdk19-windows

    Login or Signup to reply.
  7. 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.

    brew install openjdk
    

    If you have other OpenJDK versions installed, you may need to link this correct one:

    brew link --force openjdk@19
    

    To make it the default for your shell, add the following lines to ~/.zshrc:

    export JAVA_HOME="/opt/homebrew/opt/openjdk"
    export PATH="$JAVA_HOME/bin:$PATH"
    

    And then:

    source ~/.zshrc
    

    You only need to do this once.

    Then rerun: flutter doctor --android-licenses

    Login or Signup to reply.
  8. 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

    Login or Signup to reply.
  9. 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.

    1. asdf install java adoptopenjdk-19.0.0+36
    2. asdf global java adoptopenjdk-19.0.0+36
    3. Do what this comment suggests and add this to your .zshrc
      # set JAVA_HOME on every change directory
      function asdf_update_java_home {
        asdf current java 2>&1 > /dev/null
        if [[ "$?" -eq 0 ]]
        then
            export JAVA_HOME=$(asdf where java)
        fi
      }
      
      precmd() { asdf_update_java_home; }
      # end set JAVA_HOME
      
    4. exec zsh # reloads current terminal to use changed .zshrc
    5. echo $JAVA_HOME should show asdf directory one
    6. flutter doctor --android-licenses

    Machine details

    • Macbook Pro M1
    • ZSH as my shell
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search