--verbose
输出详细信息:
flutter upgrade --verbose
set PUB_HOSTED_URL=https://pub.flutter-io.cn
set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
flutter upgrade --verbose
常见问题有两个:
Flutter 升级会从 Github 下载源码,目前国内会间歇干扰 Github 连接以扶持 Gitee(码云),很像当年切断 Google 的做法。一般会遇到两种报错信息:
ProcessException: Process exited abnormally:
fatal: unable to access 'https://github.com/flutter/flutter.git/': OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
Command: git fetch --tags
ProcessException: Process exited abnormally:
fatal: unable to access 'https://github.com/flutter/flutter.git/': Failed to connect to github.com port 443: Timed out
Command: git fetch --tags
我是隔几分钟重试了几次就下载成功了,然后会 Downloading Dart SDK from Flutter engine
,Dart SDK 比较大,多等一会儿,之后会遇到下面的问题:
Running pub upgrade...
你会看到长时间卡在这一行,我上次遇到这个问题直接 Ctrl + C 强行结束了进程,然后再执行 flutter upgrade
就直接显示升级成功了,所以这次我没有中断进程而尝试排错。
直接说结果:
bin/cache/lockfile
这个文件,不要删其他的,否则还要重新下载。
flutter pub upgrade
就成功了,因为我上次不能重新 upgrade 经验,所以我继续做了下面两步。Dart
和 dart.exe
,结束 dart.exe
进程,会触发 Flutter 自动重试 pub upgrade
,显示:
Error (1): Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)
Running pub upgrade...
Dart
进程会怎样。 接下来就会开始升级 pub 了,国内源速度不是很快,但应该不会断掉,可以打开流量监控看一下,只要有速度多等一会儿就好。
同时升级了一些依赖,升级 ffi v1.0.0
,之前 ffi
转换字符串指针的用法是:
Pointrer<Utf8> ptr = UTF8.toUtf8('Testing');
String text = UTF8.fromUtf8(ptr);
后来要改成:
Pointrer<Utf8> ptr = 'Testing'.toNativeUtf8();
String text = ptr.toDartString();
但是我遇到的报错:
NoSuchMethodError: Class 'Pointer<Utf8>' has no instance method 'toDartString'
搜来搜去,还翻了源码,哪儿都没找到问题,突然想起执行了一下 flutter clean
重新运行就好了。