You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

更新Dart/Flutter后Android Studio执行Pub get报Git连接错误求助

问题说明

更新Dart、Flutter版本后在Android Studio执行Pub get/upgrade操作时报Git连接错误,错误日志核心信息如下:

C:\flutter\flutter\bin\flutter.bat --no-color pub upgrade
Resolving dependencies...
Git error. Command: `git fetch`
stdout: 
stderr: fatal: unable to connect to github.com:
github.com[0: 140.82.113.3]: errno=Unknown error

exit code: 128
pub finished with exit code 69
Process finished with exit code 69

该报错本质是Git拉取GitHub上的依赖资源时网络连接失败,和Flutter/Dart版本本身无直接关联。

修复方案

按以下优先级逐一排查操作:

  • 基础网络校验
    打开系统终端执行ping github.com,如果请求全部超时,先确认本地网络可正常访问GitHub,开启系统代理的用户先确认代理运行正常。
  • 给Git配置代理(本地有可用代理场景)
    把命令里的端口号替换为本地代理的实际HTTP端口(常见端口为7890、10809,可在代理软件设置页查看),终端执行:
    git config --global http.proxy http://127.0.0.1:替换为你的代理端口
    git config --global https.proxy http://127.0.0.1:替换为你的代理端口
    
    配置完成后执行git config --global --list确认代理参数已写入,再重新执行flutter pub get验证。
  • 清除Git无效代理配置(本地无代理场景)
    如果本地没有运行代理,但之前给Git配置过无效代理参数,执行命令清除配置:
    git config --global --unset http.proxy
    git config --global --unset https.proxy
    
  • 替换Git依赖访问协议
    若依赖拉取走SSH协议失败,可强制Git将GitHub的SSH、Git协议请求替换为HTTPS协议,终端执行:
    git config --global url."https://github.com/".insteadOf git@github.com:
    git config --global url."https://".insteadOf git://
    
  • 修复Pub缓存
    以上操作完成后仍报错的,执行flutter pub cache repair修复本地Pub损坏缓存,再重新拉取依赖。

内容的提问来源于stack exchange,提问作者Nitzan Eliyahu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.03 06:21:47