Flutter安装后出现HTTP host not reachable.

Flutter安装好配置环境变量之后在cmd运行Flutter doctor出现如下 两个问题:

HTTP host https://maven.google.com/ is not reachable.Reason: An error occurred while checking the HTTP host

HTTP host https://cloud.google.com/ is not reachable.Reason: An error occurred while checking the HTTP host

解决办法

1、找到flutter sdk的文件目录,打开下面路径文件

flutter\packages\flutter_tools\lib\src\http_host_validator.dart

2、将文件中的链接进行替换

将其中的 https://maven.google.com/ 修改为 https://dl.google.com/dl/android/maven2/(解决第一个问题)

再将 kPubDevHttpHostkgCloudHttpHost 两个常量 分别修改为 https://pub.flutter-io.cn/https://storage.flutter-io.cn/(解决第二个)

3、去到flutter\bin目录,删除cache目录下的flutter_tools.snapshot 文件

4、新开一个cmd,在cmd命令窗口重新运行flutter doctor,问题解决。

参考链接

猜你喜欢

转载自blog.csdn.net/qq_40166103/article/details/125673747