Flutter系列错误之Dart SDK is not configured

导入flutter项目,由于时间长未用,导入后提示找不到Dart SDK,第一反应就是镜像问题

于是换了n多镜像依然不好用,最后将镜像地址依然还原到谷歌临时镜像地址:

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

之后弄了个临时,依然不行,一直报错:

Downloading Dart SDK from Flutter engine <<<<<<< HEAD
52c7a1e849a170be4b2b2fe34142ca2c0a6fea1f
=======
e1e6ced81d029258d449bdec2ba3cddca9c2ca0c
>>>>>>> 0b8abb4724aa590dd0f429683339b1e045a1594d...
unzip:  cannot find or open , .zip or .ZIP.

It appears that the downloaded file is corrupt; please try again.
If this problem persists, please report the problem at:
https://github.com/flutter/flutter/issues/new?template=ACTIVATION.md

后来想到可能是git的版本出现了问题,于是重置head:

localhost:Flutter candy$     git reset head --hard
HEAD is now at 7a4c33425 cherry-pick: fix edge swiping and dropping back at starting point (#31623)

再次执行flutter doctor:

localhost:Flutter candy$ flutter doctor
Building flutter tool...
/Library/Flutter/bin/flutter: line 46: /Library/Flutter/bin/cache/dart-sdk/bin/pub: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)
/Library/Flutter/bin/flutter: line 46: /Library/Flutter/bin/cache/dart-sdk/bin/pub: No such file or directory
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (8 tries left)
/Library/Flutter/bin/flutter: line 46: /Library/Flutter/bin/cache/dart-sdk/bin/pub: No such file or directory
packages/flutter/lib/src/widgets/text_selection.dart: unmerged (2427b0cf93687a109d33887ec90d70e67109f1d6)
...
fatal: git-write-tree: error building trees
Cannot save the current index state
localhost:Flutter candy$ git pull
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm '
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.

一直提示找不到dart-sdk内部文件,注意这句话:hint: Fix them up in the work tree, and then use 'git add/rm '

然后翻找目录发现有dart-sdk文件夹下无文件,于是下载了一个dart-sdk将内容填充了进去,结果运行ok,提示有新版本:

Command 'pub upgrade' still failed after 10 tries, giving up.
localhost:Flutter candy$ flutter doctor
Building flutter tool...
  ╔════════════════════════════════════════════════════════════════════════════╗
  ║ A new version of Flutter is available!                                     ║
  ║                                                                            ║
  ║ To update to the latest version, run "flutter upgrade".                    ║
  ╚════════════════════════════════════════════════════════════════════════════╝


Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.5 18F132, locale
    zh-Hans-CN)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 11.3)
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.40.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

ok,到此执行flutter upgrade,问题解决!!!

centos服务器部署nodejs和这个问题纠结了我一天,故此分享给大家,希望对你们能有帮助!

你可能感兴趣的:(Flutter,Android,Studio,Flutter,Dart,Flutter更新,Android,Studio)