Android工具链-我为Android设备开发(Android SDK版本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.

当前回答

我在Windows 10上通过以下操作解决了这个问题:

Run the following command in a Windows command prompt or Flutter console: flutter config --android-sdk "C:\Users\'your computer name' AppData\Local\Android\Sdk" (you may need to find and enter your own SDK path) The Android SDK location could be found in the Android Studio application* → Appearance & Behavior → System Settings → Android SDK Open your Android Studio, and then → File → Settings → Appearance & Behavior → System Settings → Android SDK → SDK Tools → download Android SDK Command-line Tools (latest) and you are good to go.

其他回答

这是针对Windows的: 如果您在通过Android Studio ->设置->外观与行为->系统设置-> Android SDK -> SDK工具安装“Android SDK命令行工具(最新)”后仍然面临问题,您需要配置flutter for Android SDK路径(而不是环境变量路径)。

Android SDK将安装在程序文件下,例如(C:\Program files (x86)\Android\ Android - SDK)。如果不是这个位置,找到它安装的位置并进入bin文件夹(C:\Program Files (x86)\Android\ Android -sdk\cmdline-tools\7.0\bin)并运行

flutter config --android-sdk "C:\Program Files (x86)\Android\android-sdk"

经过这次跑扑医生,现在这个问题应该解决了。

对于macOS,我运行这个命令;

cd ~/Library/Android/sdk/tools/bin
./sdkmanager --install "cmdline-tools;latest"

然后,当我再次运行flutter doctor命令时,它确认问题已解决。

如果颤振医生说的是这样的话

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/<admin>/Library/Android/sdk
✗ cmdline-tools component is missing
  Run `path/to/sdkmanager --install "cmdline-tools;latest"`

我的/to/sdkmanager路径是:

/Users/<user>/Library/Android/sdk/tools/bin/sdkmanager

所以对我来说,解决问题的方法就是跑步:

/Users/<user>/Library/Android/sdk/tools/bin/sdkmanager --install "cmdline-tools;latest"

我的解决过程如下:

~/Library/Android/sdk/tools/bin/sdkmanager --install "cmdline-tools;latest" 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:636) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519) ... 5 more Install Android SDK Command-line Tools in Android Studio: Preferences → Appearance & Behavior → System Settings → Android SDK → SDK Tools → Android SDK Command-line Tools (latest) flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.5.0, on macOS 11.5.2 20G95 darwin-x64, locale zh-Hans-CN) [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3) [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 2020.3) [✓] IntelliJ IDEA Ultimate Edition (version 2021.2) [✓] IntelliJ IDEA Ultimate Edition (version 2021.2) [✓] Connected device (2 available) • No issues found!

适用于Linux (Ubuntu)

在你的终端复制这个命令,然后用你的用户名(不带空格)修改“你的用户名”:

/home/your user name/Android/Sdk/tools/bin/sdkmanager --install "cmdline-tools;latest"