解决flutter doctor出现Android toolchain: Android license status unknown.
作者:互联网
文章目录
问题描述
使用flutter doctor
检查开发环境,出现以下问题
wangyangyangdeMacBook-Pro:~ wangyang$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.1, on Mac OS X 10.15.7 19H2 darwin-x64, locale
zh-Hans-US)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
✗ 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 4.2)
[✓] VS Code (version 1.61.0)
[✓] Connected device (2 available)
! Doctor found issues in 1 category.
根据错误提示运行flutter doctor --android-licenses
,出现以下Java异常。
wangyangyangdeMacBook-Pro:~ wangyang$ flutter doctor --android-licenses
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
虽然这个错误不影响在Android上的编译和运行,但是本人是个强迫症,必须消灭掉!!!
解决方案
根据上面的错误显示,猜测难道是Android SDK的问题?
打开Android Studio, Preferences-Appearance & Behavior- System Settings- Android SDK-SDK Tools
发现SDK的命令行工具没有安装。
勾选,然后选择Apply,会出现安装提示.
点击OK,会出现安装进度。
安装完成后,再次运行flutter doctor
,已经没有错误了。OK 完美!
wangyangyangdeMacBook-Pro:~ wangyang$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.1, on Mac OS X 10.15.7 19H2 darwin-x64, locale
zh-Hans-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.61.0)
[✓] Connected device (2 available)
• No issues found!
标签:status,java,doctor,toolchain,Android,SDK,flutter,android 来源: https://blog.csdn.net/adojayfan/article/details/120747258