完整报错:
Building flutter tool...
Because flutter_tools depends on sse 3.5.0 which doesn't match any versions, version solving failed.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)
Because flutter_tools depends on sse 3.5.0 which doesn't match any versions, version solving failed.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (8 tries left)
Because flutter_tools depends on sse 3.5.0 which doesn't match any versions, version solving failed.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (7 tries left)
Because flutter_tools depends on sse 3.5.0 which doesn't match any versions, version solving failed.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (6 tries left)
Because flutter_tools depends on sse 3.5.0 which doesn't match any versions, version solving failed.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (5 tries left)
Because flutter_tools depends on sse 3.5.0 which doesn't match any versions, version solving failed.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (4 tries left)
Because flutter_tools depends on sse 3.5.0 which doesn't match any versions, version solving failed.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (3 tries left)
Because flutter_tools depends on sse 3.5.0 which doesn't match any versions, version solving failed.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (2 tries left)
Because flutter_tools depends on sse 3.5.0 which doesn't match any versions, version solving failed.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (1 tries left)
Command 'pub upgrade' still failed after 10 tries, giving up.
报错原因:根据flutter中文网安装flutter的时候,在.bash_profile文件中设置了环境变量PUB_HOSTED_URL为https://pub.flutter-io.cn,而官方地址是https://pub.dartlang.org,这两个地址的最新版本不一致,所以导致出现了这个问题。
解决办法:
参考这边文档https://blog.csdn.net/leyuuu/article/details/103873884的解决方法
暂时删除PUB_HOSTED_URL
使用代理 set https_proxy 127.0.0.1:1080
或者
查看下最后Sync时间PUB_HOSTED_URL
更换其他镜像
结果:采用删除PUB_HOSTED_URL不好用,于是使用更换其他镜像的方法
flutter官网提供的镜像如下:https://flutter.cn/community/china
如下列表为目前在国内提供镜像的社区以及其镜像配置,由于镜像的实现方式有所不同,可能回导致数据的滞后等问题。我们制作了一个 镜像可用性监控页面 供参考。
社区主镜像,采用多种方式同步 Flutter 开发者资源(推荐)。
content_copy
$ export PUB_HOSTED_URL=https://pub.flutter-io.cn
$ export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
使用反向代理方式建立 Flutter 镜像,数据与站源实时同步。 Pub API 返回值未做处理,可能造成无法访问的情况。
content_copy
$ export PUB_HOSTED_URL=https://dart-pub.mirrors.sjtug.sjtu.edu.cn
$ export FLUTTER_STORAGE_BASE_URL=https://mirrors.sjtug.sjtu.edu.cn
采取自定义脚本定时主动抓取策略,并配置了完善的回源策略(推荐)。查看帮助文档: Flutter 镜像安装帮助, Pub 镜像安装帮助。
content_copy
$ export PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub
$ export FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter
基于 TUNA 协会的镜像服务,数据策略与 TUNA 一致,通过非教育网的域名访问(建议选择 TUNA)。
content_copy
$ export PUB_HOSTED_URL=http://mirrors.cnnic.cn/dart-pub
$ export FLUTTER_STORAGE_BASE_URL=http://mirrors.cnnic.cn/flutter
1.命令行操作-打开配置文件
vim ~/.bash_profile
更换新的镜像配置,关闭文件,并刷新
source ~/.bash_profile
2.重新更新flutter
flutter upgrade
3.更新很长时间,毫无反应,最终放弃了,不知道是不是我耐心不够。
继续寻找解决方案:版本回退
https://blog.csdn.net/wangyajuncsd/article/details/104439108?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3
4.然后选了个几天前的版本,回退回去,重新输入命令行flutter doctor就不报错了。