1

I'm very new to macOS and Flutter on Android Studio, Im trying to build an app, but I still get the same error:

Running Gradle task 'assembleDebug'...

ERROR: JAVA_HOME is set to an invalid directory: /Library/Java/JavaVirtualMachines/openjdk-16.0.2/Contents/Home

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

I already installed Java_home, followed many tutorials and if I test the java version I will get:

openjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment (build 16.0.2+7-67)
OpenJDK 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)

when I check from terminal:

 ashraf@Ashrafs-MacBook-Pro ~ % /usr/libexec/java_home                  
/Users/ashraf/Library/Java/JavaVirtualMachines/openjdk-16.0.2/Contents/Home

Note: if Im using iPhone Simulator it works fine, this error comes up only on android emulator

mokagio
  • 16,391
  • 3
  • 51
  • 58
Ismail Muhammad
  • 320
  • 3
  • 15
  • 2
    Check this https://stackoverflow.com/a/66268297/2196176 – Sunny Aug 12 '21 at 09:07
  • check my answer here and see the comments below it, see if it works for u: https://stackoverflow.com/questions/68729690/how-i-can-fix-android-license-status-unknown-in-flutter/68730152#68730152 – Benyamin Aug 12 '21 at 09:43
  • it is not clear for me, I just bought macbook pro m1 and installed all applications from its original sources which means up-to-date – Ismail Muhammad Aug 12 '21 at 09:50
  • Have you try to build fresh native android project? If it works then there is no problem with your JDK, instead you need to re-install your JDK – cahyo Oct 21 '21 at 03:44

0 Answers0