Search code examples
javaandroidflutterapple-silicon

Flutter still using older java after update. MacOS apple silicon


I have been trying to update my android SDK to latest for play store requirements. But since I updated the sdk flutter won't compile anymore

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc3)
• Android SDK at /Users/shababhaidersiddique/Library/Android/sdk
• Platform android-35, build-tools 35.0.0-rc3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
✗ Android license status unknown.
  Run `flutter doctor --android-licenses` to accept the SDK licenses.
  See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

I cannot sign the android licenses because its using OpenJDK runtime build 11

$ flutter doctor --android-licenses
This tool requires JDK 17 or later. Your version was detected as 11.0.10.
To override this check, set SKIP_JDK_VERSION_CHECK.
Android sdkmanager tool was found, but failed to run
(/Users/shababhaidersiddique/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager): "exited code 1".
Try re-installing or updating your Android SDK,
visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions.

Even though I have openjdk22

$ java --version                   

openjdk 22.0.2 2024-07-16 OpenJDK Runtime Environment Homebrew (build 22.0.2) OpenJDK 64-Bit Server VM Homebrew (build 22.0.2, mixed mode, sharing)

I have re installed openjdk with

brew reinstall openjdk

many times and followed the provided hints to add symlink,PATH and CPPFLAGS

I don't know why flutter still finding java11 runtime. Would really appreciate any help.

Thanks in advance


Solution

  • No matter what i tried flutter always use the embedded JDK. So the solution was to remove android studio and install the latest version which came bundled with latest jdk.