~ %>flutter doctor [
Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel stable, 2.2.3, on macOS 11.5.2 20G95 darwin-arm, locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
? 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.
[?] Xcode - develop for iOS and macOS
[?] Chrome - develop for the web
[?] Android Studio (version 2020.3)
然后运行?`flutter doctor --android-licenses` ,结果报错如下:
~ %>flutter doctor --android-licenses [1]
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
恶心了,java版本问题。我当前使用的jdk11,众所周知,jdk在9时对目录结构做了比较大的调整,所以方便jdk版本切换,决定安装jdk8,为了在m1版本mac上安装jdk找到了zuku的jdk
https://www.azul.com/downloads/?version=java-8-lts&os=macos&architecture=arm-64-bit&package=jdk
当然先是卸载了之前的jdk。安装之后,看到了flutter添加安卓licenses的官方文档,
才知道还必须设置JAVA_HOME的环境变量,如下:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
?然后再次flutter doctor --android-licenses,成功了。
|