问题描述
C:\Users\Administrator>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.16.1, on Microsoft Windows [版本 10.0.18363.592], locale zh-CN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 34.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
[X] Visual Studio - develop Windows apps
X Visual Studio not installed; this is necessary to develop Windows apps.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2022.3)
[√] IntelliJ IDEA Ultimate Edition (version 2023.2)
[√] Connected device (3 available)
[!] Network resources
X A cryptographic error occurred while checking "https://storage.googleapis.com/": Connection terminated during
handshake
You may be experiencing a man-in-the-middle attack, your network may be compromised, or you may have malware
installed on your computer.
X A network error occurred while checking "https://maven.google.com/": 信号灯超时时间已到
! Doctor found issues in 3 categories.
解决办法
问题1:cmdline-tools component is missing
安装Android SDK Command-line Tools(latest)
File -> Settings -> Preferences -> Appearance & behavior -> System Settings (dropdown) -> AndroidSDK->SDK Tools ->Android SDK Command-line Tools (latest)-> Apply
问题2:Android license status unknown.
执行命令
flutter doctor --android-licenses
问题3:Visual Studio not installed; this is necessary to develop Windows apps.
安装 vs
根据Windows的版本选择对应的Visual Studio版本下载
https://visualstudio.microsoft.com/zh-hans/downloads/
问题4:A network error occurred while checking “https://maven.google.com/”: 信号灯超时时间已到
修改文件D:\dev\flutter\packages\flutter_tools\lib\src\http_host_validator.dart
中的const String kMaven = 'https://maven.google.com/';
为const String kMaven = 'https://maven.aliyun.com/repository/google/';
问题5:A cryptographic error occurred while checking “https://storage.googleapis.com/”: Connection terminated during handshake
- 添加环境变量
在用户变量中新增两个变量如下:
PUB_HOSTED_URL 设置为 https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL 设置为 https://storage.flutter-io.cn
- 设置代理
set HTTP_PROXY=http://127.0.0.1:7890
set HTTPS_PROXY=http://127.0.0.1:7890
set NO_PROXY=localhost,127.0.0.1,::1
设置代理的方式仅对当前命令提示符窗口有效,关闭窗口失效
重新检测
C:\Users\Administrator>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.16.1, on Microsoft Windows [版本 10.0.18363.592], locale zh-CN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2019 16.11.32)
[√] Android Studio (version 2022.3)
[√] IntelliJ IDEA Ultimate Edition (version 2023.2)
[√] Proxy Configuration
[√] Connected device (3 available)
[√] Network resources
• No issues found!
参考
https://flutter.cn/docs/get-started/install/windows
https://github.com/flutter/flutter/issues/24854#issuecomment-525105693