skip to Main Content

The version of my java is 21.

However the error says it’s looking for v17.

I tried to find and fix the problem. But there aren’t any solution to this available. I am trying to avoid reinstalling Android Studio.

This is mac m1. Please guide me here.

[Cannot execute /usr/lib/jvm/java-17-openjdk-amd64/bin/java to determine the version1

2

Answers


  1. Chosen as BEST ANSWER

    I was able to resolve this with the help of chatgpt...

    Flutter was pointing to the wrong jdk all this while...

    Run the cmd: flutter config --list

    I got this...

    All Settings:
    enable-web: true
    ...
    ...
    jdk-dir: /usr/lib/jvm/java-17-openjdk-amd64/
    android-studio-dir: /Applications/Android Studio.app

    jdk-dir was set to old version of java...

    I was able to update this with the following cmd

    flutter config --jdk-dir /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home

    Now when I run flutter doctor, I'm getting this

    flutter doctor


  2. I think the issue lies with the version of java used by default. Android studio V34 (at least the gradle version, which some plugins may use) uses Java 17. Take a look at https://developer.android.com/build/jdks#compileSdk and see if this might help.

    PS – I don’t think you need to reinstall Android Studio, just install the version of Java it wants

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search