Hello I am on mac and I changed the sdk version as many tutorials say. If I run java --version
I get this:
openjdk version "11.0.19" 2023-04-18
OpenJDK Runtime Environment Homebrew (build 11.0.19+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.19+0, mixed mode)
The problem is when I run flutter doctor --verbose
I get this on android studio:
[✓] Android Studio (version 2022.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
The JDK versions are different. And when I try to run a flutter project I get this error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @52a71430
Additional information:
When I open my flutter project by the android folder in android studio I can configure
project settings
and select the jdk version.This works only if I run the app inside the android folder in android studio. If I run it from the root it throws the same error.
The command output of
/usr/libexec/java_home -V
is this:
Matching Java Virtual Machines (1):
11.0.19 (arm64) "Homebrew" - "OpenJDK 11.0.19" /opt/homebrew/Cellar/openjdk@11/11.0.19/libexec/openjdk.jdk/Contents/Home
/opt/homebrew/Cellar/openjdk@11/11.0.19/libexec/openjdk.jdk/Contents/Home
- In my ~/.zshrc I have an export of
export JAVA_HOME='/opt/homebrew/Cellar/openjdk@11/11.0.19/libexec/openjdk.jdk/Contents/Home'
Is there a way to solve this?