遇到报错:
Launching lib\main.dart on Windows in debug mode...
Exception: Unable to find suitable Visual Studio toolchain. Please run `flutter doctor` for more details.
异常原因:
运行桌面版时底层需要安装 Window SDK 10,需要注意的是 Visual Studio版本必须 大于等于 2019。
我们在命令行输入flutter doctor
,查看当前的flutter环境存在的问题。
C:\Users\Administrator>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [版本 10.0.19044.1889], locale zh-CN)
[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.
[√] Chrome - develop for the web
[!] Visual Studio - develop for Windows (Visual Studio Professional 2017 15.9.44)
X Visual Studio 2019 or later is required.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 3.5)
[√] IntelliJ IDEA Ultimate Edition (version 2019.3)
[√] Connected device (2 available)
在创建Flutter项目的时候,存在环境中底层组件 Windows 10 SDK的缺失。
这里需要安装Visual Studio Professional 版本号 >= 2019,我的版本是2017不符合,只能进行卸载然后重装。
解决方案:
等待下载并安装成功:
需要注意
Visual Studio版本必须 大于等于 2019,个人原始是2017版本,因为用于移动端开发,所以未进行更换。