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.

当前回答

MacOS用户

如果已经安装了android studio,只需运行:

flutter config --android-sdk "/Users/$USER/Library/Android/sdk" & flutter doctor --android-licenses

其他回答

我的解决方案是打开Android Studio,进入SDK管理器,切换到SDK工具选项卡,并检查Android SDK命令行工具(最新)。

不要忘记将SDK中的工具和平台工具文件夹添加到PATH中。

Windows上的Android SDK管理器截图

从SDK管理器中安装工具请参见附件截图。

我从Android Studio安装了Android SDK平台工具。这帮助我解决了这个错误。

安装前错误

从Android Studio安装平台工具

安装平台工具后

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

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

flutter config --android-sdk=""