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.

当前回答

由于我的Android Studio开始屏幕看起来与上面的答案不同,我想分享我的解决方案:

打开Android Studio,点击欢迎屏幕上的“more actions”。 点击“SDK管理器”

在“*首选项”窗口转到“*SDK Tools•”选项卡 选择“Android SDK命令行工具(最新)”复选框。 点击“应用”。

其他回答

你必须安装Android SDK命令行工具。 要做到这一点,调用菜单命令File→Settings→Android SDK并下载最新的。

您必须在“设置”窗口左侧选择“Android SDK”。在“外观与行为”→“系统设置”下。

如果您已经下载了cmdline-tools和Android SDK,请确保Flutter没有在错误的目录中查找:

flutter config --android-sdk=""

由于我的Android Studio开始屏幕看起来与上面的答案不同,我想分享我的解决方案:

打开Android Studio,点击欢迎屏幕上的“more actions”。 点击“SDK管理器”

在“*首选项”窗口转到“*SDK Tools•”选项卡 选择“Android SDK命令行工具(最新)”复选框。 点击“应用”。

我在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.

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

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

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