安装好 Flutter SDK 之后,官方建议使用flutter doctor
检查 Flutter SDK 的相关配置信息。
如果 Android Studio 安装 Android SDK 的时候选择了自定义路径,Flutter 提示无法定位 Android SDK 的安装位置。以下为报错信息:
[X] Android toolchain - develop for Android devices
X Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
提示给出了修复建议,使用flutter config --android-sdk [Android SDK 路径]
命令设置 Android SDK 的自定义路径。设置时去掉多余的[]
符号。
以下是设置成功后显示的信息:
PS C:\Users\shiramashiro> flutter config --android-sdk E:\DevKits\Android\Sdks
Setting "android-sdk" value to "E:\DevKits\Android\Sdks".
再次使用flutter doctor
检查 Flutter SDK 的配置信息。
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses