我一直在尝试将我的 Android SDK 更新到最新版本以满足 Play 商店的要求。但是自从我更新了sdk flutter就无法再编译了
[!] 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.
我无法签署 Android 许可证,因为它使用 OpenJDK 运行时版本 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.
即使我有openjdk22
$ java --version
openjdk 22.0.2 2024-07-16 OpenJDK 运行时环境 Homebrew(内部版本 22.0.2) OpenJDK 64位服务器VM Homebrew(构建22.0.2,混合模式,共享)
我已经重新安装了openjdk
brew reinstall openjdk
多次按照提供的提示添加符号链接、PATH 和 CPPFLAGS
我不知道为什么flutter仍然找到java11运行时。非常感谢任何帮助。
提前致谢
无论我尝试什么,flutter 总是使用嵌入式 JDK。所以解决方案是删除 android studio 并安装与最新 jdk 捆绑在一起的最新版本。