安装Flutter SDK
- Windows安装
flutter官网下载flutter sdk包
2.解压到C盘除去program file相关的目录(最好自己创建一个新的目录,因为放在program file等目录需要特殊的权限,会出现问题)
-
Android 需要安装Android SDK ,同理苹果开发也需要对应的环境
-
安装ide工具(Android Studio ,visual studio code)都可以
-
运行
flutter doctor
检查安装环境
PS C:\Android\flutter\bin> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.19042.1645], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.0-preview)
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
[!] Visual Studio - develop for Windows (Visual Studio Enterprise 2022 17.1.0)
X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop
development with C++" workload, and include these components:
MSVC v142 - VS 2019 C++ x64/x86 build tools
- If there are multiple build tool versions available, install the latest
C++ CMake tools for Windows
Windows 10 SDK
[√] Android Studio (version 2021.1)
[√] VS Code, 64-bit edition (version 1.66.1)
[√] Connected device (3 available)
[!] HTTP Host Availability
X HTTP host https://maven.google.com/ is not reachable. Reason: An error occurred while checking the HTTP host:
Failed host lookup: 'maven.google.com'
X HTTP host https://pub.dev/ is not reachable. Reason: An error occurred while checking the HTTP host: Failed host
lookup: 'pub.dev'
X HTTP host https://cloud.google.com/ is not reachable. Reason: An error occurred while checking the HTTP host:
Failed host lookup: 'cloud.google.com'
! Doctor found issues in 3 categories.
提示错误
-Waiting for another flutter command to release the startup lock...
- 看到任务管理器里面有9个dart服务在运行,因此删除不了 flutter 安装目录下的bin/cache/lockfile
文件,可以使用下面的命令停止dart服务的运行
// Linux
killall -9 dart
// Windows
taskkill /F /IM dart.exe
C:\WINDOWS\system32>taskkill /F /IM dart.exe
SUCCESS: The process "dart.exe" with PID 58904 has been terminated.
SUCCESS: The process "dart.exe" with PID 59660 has been terminated.
SUCCESS: The process "dart.exe" with PID 64856 has been terminated.
SUCCESS: The process "dart.exe" with PID 64820 has been terminated.
SUCCESS: The process "dart.exe" with PID 69264 has been terminated.
SUCCESS: The process "dart.exe" with PID 65924 has been terminated.
SUCCESS: The process "dart.exe" with PID 61544 has been terminated.
SUCCESS: The process "dart.exe" with PID 68612 has been terminated.
SUCCESS: The process "dart.exe" with PID 66868 has been terminated.
SUCCESS: The process "dart.exe" with PID 55608 has been terminated.
SUCCESS: The process "dart.exe" with PID 67136 has been terminated.
SUCCESS: The process "dart.exe" with PID 73776 has been terminated.
-
HTTP host https://maven.google.com/ is not reachable. Reason: An error occurred while checking the HTTP host: Failed host lookup: 'maven.google.com'
- 替换flutter\packages\flutter_tools\lib\src\http_host_validator.dart
目录下的'maven.google.com'
为'https://dl.google.com/dl/android/maven2/'
- 关闭所有命令行窗口,再打开命令行窗口
- 去到flutter\bin
目录,删除cache
文件夹
- 重新运行flutter doctor
Could not resolve URL "https://pub.flutter-io.cn".
pub get failed (server unavailable) -- attempting retry
powershell中运行文章来源:https://www.toymoban.com/news/detail-479730.html
setx PUB_HOSTED_URL "https://pub.flutter-io.cn"
setx FLUTTER_STORAGE_BASE_URL "https://storage.flutter-io.cn"
参考链接
如何解决“Waiting for another flutter command to …”
[转]Windows构建Flutter环境,无法访问maven.google.com
Step by step setting up flutter and pub mirrors in china using Windows Operating System #46641
【flutter】pub get failed (server unavailable) – attempting解决办法
vscode 安装flutter遇到的坑文章来源地址https://www.toymoban.com/news/detail-479730.html
到了这里,关于Flutter 安装踩坑记录 HTTP host https://pub.dev/ is not reachable.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!