avatar

ShīnChvën ✨

Effective Accelerationism

Powered by Druid

修复 Flutter doctor 的 HTTP Host availability 问题(无需修改SDK源码)

Tue Apr 04 2023

如果你在东方墙国做软件开发,总会遇到很多人为制造的恶心问题。比如初次安装 Flutter SDK 时,运行 flutter doctor 时,在最后一步HTTP Host availability check is taking a long time...会变得很慢,最后报错:

HTTP Host availability check is taking a long time...[!] HTTP Host Availability
    ✗ HTTP host "https://pub.dev/" is not reachable. Reason: An error occurred
      while checking the HTTP host: Operation timed out

这是因为 Flutter 默认的 Android Maven 仓库被墙。

要解决这个问题很简单,只需在环境变量中配置FLUTTER_STORAGE_BASE_URL,将其指向一个可访问的 maven 镜像地址即可。

export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PUB_HOSTED_URL=https://pub.flutter-io.cn # 同步你还可以增加这个环境变量来配置 pub 仓库镜像
# export FLUTTER_STORAGE_BASE_URL=https://dl.google.com/dl/android/maven2/

References