skip to Main Content

I’am facing below error while running flutter doctor on may Mac machine with M4c chip. Can someone please help me to resolve this issue. Below is the error after running flutter doctor -v command.

`[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/amit/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at:
      /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java
    ✗ Cannot execute
      /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home/bin/java to
      determine the version`

I tried every solution out there on internet but not working. Please help me with a solution , this is first time i am using MacOs.

Thanks.

2

Answers


  1. Check if java -version returns the proper version in terminal. You may need to do some tinkering to point your machine to your java installation. Refer to this answer for help with Java. https://stackoverflow.com/a/19663996/19633851

    Login or Signup to reply.
  2. Let’s try to simplify the troubleshooting process first:

    Please go to your Android Studio’s File > Project Structure…

    Then select your installed Java SDK by this way:

    img

    Note: You can also verify there if you properly selected the corresponding Java SDK.

    After selecting, click apply, and then ok.

    Please consider doing File > Invalidate Caches…

    After doing these things. Execute flutter doctor -v again.

    Make sure you set the proper PATH and JAVA_HOME in your ENVIRONMENT VARIABLES. Here’s what I set for PATH: C:Program FilesJavajdk-21bin and for JAVA HOME: C:Program FilesJavajdk-21 it should be added in your system variables section.

    UPDATE

    For instant checking of your PATH and JAVA_HOME setup,

    In Windows, open your command prompt, then execute these commands:

    for checking your PATH
    where java
    
    for checking your JAVA_HOME
    echo %JAVA_HOME%
    

    I hope it helps!

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