美文网首页
Flutter Upgrade升级提示You are not c

Flutter Upgrade升级提示You are not c

作者: 前端技术小咖 | 来源:发表于2021-06-10 12:32 被阅读0次

Futter 2.2版本在Google I/O 2021发布了,作为一个移动端研发爱好者肯定第一时间升级尝鲜,但好事多磨,执行flutter upgrade就报错了,错误信息如下:

$ flutter upgrade
You are not currently on a release branch. Use git to check out an official branch ('stable', 'beta', 'dev', or 'master') and retry, for example:
  git checkout stable
错误原因:

发生这种错误一般都是之前使用git checkout的方式切换了flutter的分支,并且切换的分支在stable, beta, dev,和 master四个分支之外。因此解决问题的方法就很明确了,使用flutter channel命令将分支切回到stable, beta, dev,和 master四个分支中的一个就可以了

解决问题:
1)执行flutter channel [channel]命令切换channel

执行命令flutter channel [channel]命令可以快速切换channel。flutter提供了4个 release channels: stable, beta, dev, 和 master。推荐大家使用 stable channels(稳定版)。

flutter channel stable

执行完命令后看到一下信息意味着我们已经成功完成切换channel

Switching to flutter channel 'stable'...
git: Switched to branch 'stable'
git: Your branch and 'origin/stable' have diverged,
git: and have 11 and 3123 different commits each, respectively.
git:   (use "git pull" to merge the remote branch into yours)
Successfully switched to flutter channel 'stable'.
To ensure that you're on the latest build from this channel, run 'flutter upgrade'

还可以使用flutter channel来查看当前的channel, 在下面的示例中签名有*的就是当前的channel

$ flutter channel

Waiting for another flutter command to release the startup lock...
Flutter channels:
  master
  dev
  beta
* stable
2) 再次执行flutter upgrade升级flutter
flutter upgrade

执行以上命令后即可看到以下信息即意味着开始升级了:

Upgrading Flutter from /Users/user/Library/flutter...
Downloading Dart SDK from Flutter engine 0fdb562ac8068ce3dda6b69aca3f355f4d1d2718...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0  200M    0 1336k    0     0   783k      0  0:04:21  0:00:01  0:04:20  782k
  1  200M    1 3452k    0     0  1289k      0  0:02:38  0:00:02  0:02:36 1289k
  2  200M    2 5820k    0     0  1570k      0  0:02:10  0:00:03  0:02:07 1570k
  3  200M    3 8012k    0     0  1717k      0  0:01:59  0:00:04  0:01:55 1716k
  5  200M    5 10.0M    0     0  1810k      0  0:01:53  0:00:05  0:01:48 2050k
  6  200M    6 12.4M    0     0  1911k      0  0:01:47  0:00:06  0:01:41 2299k
  7  200M    7 14.5M    0     0  1938k      0  0:01:45  0:00:07  0:01:38 2286k
  8  200M    8 16.6M    0     0  1956k      0  0:01:44  0:00:08  0:01:36 2242k
  9  200M    9 19.0M    0     0  2015k      0  0:01:41  0:00:09  0:01:32 2293k
 10  200M   10 21.1M    0     0  2007k      0  0:01:42  0:00:10  0:01:32 2224k
 11  200M   11 23.2M    0     0  2040k      0  0:01:40  0:00:11  0:01:29 2212k
......
Building flutter tool...

Upgrading engine...
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Downloading Material fonts...                                    1,139ms
Downloading Gradle Wrapper...                                       54ms
Downloading android-arm-profile/darwin-x64 tools...              1,552ms
Downloading android-arm-release/darwin-x64 tools...              1,355ms
Downloading android-arm64-profile/darwin-x64 tools...            1,575ms
Downloading android-arm64-release/darwin-x64 tools...            1,355ms
Downloading android-x64-profile/darwin-x64 tools...              1,777ms
Downloading android-x64-release/darwin-x64 tools...              1,348ms
Downloading android-x86 tools...                                   10.5s
Downloading android-x64 tools...                                   10.3s
Downloading android-arm tools...                                    5.1s
Downloading android-arm-profile tools...                         2,390ms
Downloading android-arm-release tools...                         1,805ms
Downloading android-arm64 tools...                                  4.8s
Downloading android-arm64-profile tools...                       2,797ms
Downloading android-arm64-release tools...                       2,074ms
Downloading android-x64-profile tools...                         2,704ms
Downloading android-x64-release tools...                         2,124ms
Downloading android-x86-jit-release tools...                        3.3s
Downloading ios tools...                                           19.3s
Downloading ios-profile tools...                                   14.0s
Downloading ios-release tools...                                   94.2s
Downloading Web SDK...                                             15.4s
Downloading package sky_engine...                                  868ms
Downloading flutter_patched_sdk tools...                         1,534ms
Downloading flutter_patched_sdk_product tools...                 1,593ms
Downloading darwin-x64 tools...                                    15.8s
Downloading darwin-x64/font-subset tools...                      1,425ms

Flutter 2.2.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 02c026b03c (13 days ago) • 2021-05-27 12:24:44 -0700
Engine • revision 0fdb562ac8
Tools • Dart 2.13.1

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.1, on Mac OS X 10.15.7 19H15 darwin-x64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[!] Xcode - develop for iOS and macOS
    ! CocoaPods 1.9.3 out of date (1.10.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3)
[✓] VS Code (version 1.53.1)
[✓] Connected device (1 available)

! Doctor found issues in 1 category.

从上面的升级日志可以看出,升级包安装完成后,flutter还会很贴心的帮我们执行一下flutter doctor命令。查看没有任何报错信息后,那么就要恭喜了,您已顺利完成flutter的升级了。

相关文章

网友评论

      本文标题:Flutter Upgrade升级提示You are not c

      本文链接:https://www.haomeiwen.com/subject/arpueltx.html