修改 pubspec.yaml 文件增加第三方庫之后,AndroidStudio 像往常一樣提示 需要 package get。
然后一直卡在
Running "flutter packages get" in flutter_project_name...
等啊等,等不了想重新執行package get,結果
Waiting for another flutter command to release the startup lock...
解決方法:
打開flutter安裝文件夾,找到\bin\cache中的lockfile文件,刪除之,就可以重新package get了。
然額還是一只卡住。。。
Flutter畢竟是Google的,查了下原來還有Using-Flutter-in-China
大概意思就是 把 package 獲取地址改為訪問國內鏡像站就可以了。
-
Linux 或 Mac
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
-
Windows
PUB_HOSTED_URL ===== https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL ===== https://storage.flutter-io.cn
增加兩個環境變量,然后執行一下 flutter doctor命令。問題完美解決。