从Android Studio转移阵地到VScode,发现flutter doctor的时候有红色,那个红X看的我浑身难受,好不容易解决了以后,找配置启动项的位置又找了半天。。。无语死了
长话短说,下面附上flutter doctor问题以及如何在vscode中配置启动参数项。
flutter doctor报错如下:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.19042.1348], locale zh-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
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.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[√] Android Studio (version 2020.3)
解决方案:
需要打开一个Android Studio,通过左上角工具栏Files => Settig =>搜索Android SDK,选择SDK Tools,找到Android SDKCommand-line Tools(latest),选中后点击右下角应用(apply),然后等待下载,完成点击Finish,选择OK ,完成。
再次运行flutter doctor全部绿色。
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.19042.1348], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[√] Chrome - develop for the web
[√] Android Studio (version 2020.3)
二、启动项配置:
在项目中找到lauch.json文件,没有的话可以点击左侧工具栏的debug,点击create lauch.json自动创建。下文为flutter启动项初始配置:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Flutter",
"request": "launch",
"type": "dart"
}
]
}
只需在type后追加"args": [ "aaaaa=1111111", "bbbbb=222222","ccccc=33333"],即可成功配置初始参数。修改后如下:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Flutter",
"request": "launch",
"type": "dart",
"args": [parames1=canshu1,parames2=canshu2]
}
]
}
完成。