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