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.

当前回答

对我来说,运行这个命令效果很好:

flutter config --android-sdk /path/to/your/sdk

其他回答

Windows上的Android SDK管理器截图

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

适用于Linux (Ubuntu)

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

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

我在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用户

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

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

如果您已经从Android Studio安装了最新的cmd行工具,但它仍然给出错误,那么您应该执行以下操作。

如果你已经将Android SDK安装到一个自定义目录,那么你需要复制SDK文件夹的路径。然后你要去编辑环境变量,点击New give 一个变量名ANDROID_SDK_ROOT。还有一个变量值:SDK文件夹的路径。 单击OK。

在较旧版本的Flutter中,此错误随解决方案一起出现(创建ANDROID_SDK_ROOT),但在新版本中它没有显示这一点。