解决flutter doctor出现Android license status unknown或cmdline-tools component is missing

简介: 解决flutter doctor出现Android license status unknown或cmdline-tools component is missing

问题描述

使用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)
  X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ 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!


相关文章
|
3月前
|
Java 开发工具 Maven
Flutter和Android中覆盖gradle中的repositories仓库地址
Flutter和Android中覆盖gradle中的repositories仓库地址
188 4
|
3月前
|
XML 安全 Android开发
Flutter配置Android和IOS允许http访问
Flutter配置Android和IOS允许http访问
111 3
|
3月前
|
Java Android开发
添加Flutter模块到已有项目(Android)
添加Flutter模块到已有项目(Android)
46 3
|
3月前
|
开发工具 Android开发
Flutter: Android SDK not found at this location,Android Studio not found at xxx
Flutter: Android SDK not found at this location,Android Studio not found at xxx
157 2
|
3月前
|
开发工具 Android开发
解决Android Studio编译提示NDK is missing a “platforms“ directory
解决Android Studio编译提示NDK is missing a “platforms“ directory
191 1
|
4月前
|
Dart API 开发工具
Flutter Android 14 强制升级说明 2024
猫哥我也是心大,当群友问我 flutter 如何升级编译 Android 14 时才发现需要提交新版本。
107 0
Flutter Android 14 强制升级说明 2024
|
5月前
|
开发框架 Dart 开发工具
一个Android项目怎么判断是flutter
【6月更文挑战第6天】
106 2
|
4月前
|
Dart Android开发 Windows
Flutter和Native 通信 android端
Flutter和Native 通信 android端
|
5月前
|
编译器 开发工具 Android开发
java.io.FileNotFoundException: ...my_flutter/.android/include_flutter.groovy
java.io.FileNotFoundException: ...my_flutter/.android/include_flutter.groovy
63 0
|
6月前
|
数据库 Android开发
Android数据库框架-GreenDao入门,2024年最新flutter 页面跳转动画
Android数据库框架-GreenDao入门,2024年最新flutter 页面跳转动画
Android数据库框架-GreenDao入门,2024年最新flutter 页面跳转动画