【问题标题】:The current Flutter SDK version is 0.0.0-unknown当前 Flutter SDK 版本为 0.0.0-未知
【发布时间】:2020-05-09 04:02:19
【问题描述】:

我没有使用 GIT。正如我看到的一些帖子/问题,用户提到他们正在使用 GIT,因此他们遇到了错误。

昨天,我添加了 Image Cropper 插件,然后我重新启动了机器。重启后开始报错。

The current Flutter SDK version is 0.0.0-unknown.

Because image_cropper 1.2.1 requires Flutter SDK version ^1.12.13 and no versions of image_cropper match >1.2.1 <2.0.0, image_cropper ^1.2.1 is forbidden.
So, because demoapp depends on image_cropper ^1.2.1, version solving failed.
pub get failed (1; So, because demoapp depends on image_cropper ^1.2.1, version solving failed.)
Exited (1)

我运行 Flutter version 命令 -> 下面是输出。

Flutter 1.12.13+hotfix.9 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f139b11009 (6 weeks ago) • 2020-03-30 13:57:30 -0700
Engine • revision af51afceb8
Tools • Dart 2.7.2

我做了 Flutter Clean 和 Flutter Pub Get 他们都没有解决问题。

我运行 Flutter Doctor,这是输出。

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.3 19D76, locale en-IN)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✗] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ✗ CocoaPods not installed.
        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 install:
        sudo gem install cocoapods
[✓] Android Studio (version 3.1)
[✓] VS Code (version 1.44.2)
[✓] Connected device (1 available)

! Doctor found issues in 1 category.

我从一开始就没有使用 Xcode。

关于如何解决此问题的任何建议。

编辑

我通过运行 echo $PATH 检查了路径。

/Users/rahul/Desktop/flutter/bin

路径也在那里。

编辑 2 Flutter 升级也没有帮助。

【问题讨论】:

  • 它是否与stackoverflow.com/questions/60897315/… 有关 - 我描述了 pubspec.lock 和 pubspec.yaml 如何具有用于 Flutter 版本控制的奇怪语法。或者,Flutter 可能已经损坏并且 Flutter 医生没有看到它。在这种情况下,重新安装 Flutter 应该是一个简单的解决方法。

标签: flutter


【解决方案1】:

  1. 首先重新启动系统。
  2. 打开你下载的Flutter SDK zip文件夹(你从官网下载flutter sdk时得到的文件夹)并复制 文件夹
  3. 从系统中现有的 Flutter sdk 位置(您之前提取的)中删除这两个文件,然后再次粘贴这些文件。
  4. 再次打开 android studio 并单击“获取依赖项”按钮重试。
  5. 点击运行应用程序。
  6. 应用程序将成功运行。

【讨论】:

    【解决方案2】:

    如果您在 Mac OS 上遇到这种情况,只需按照描述中的说明安装 homebrew https://brew.sh

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

    然后安装 git

    brew install git

    【讨论】:

      【解决方案3】:

      如果仍然显示 Flutter 版本为 0.0.0-unknown,请尝试运行 Flutter Doctor,那么大多数情况下您的 Flutter 安装已损坏。 请按照以下链接中提到的步骤操作。 https://github.com/flutter/flutter/wiki/Workarounds-for-common-issues#flutter-installation-corrupted

      【讨论】:

        【解决方案4】:

        尝试在 Flutter 安装文件夹中运行 git checkout stable。 我在 Windows 中遇到了同样的问题,这个修复对我有用 (对不起,如果我的英语不好:()

        【讨论】:

        • 它不在 Windows 上,XCode 需要正确更新,以及可可豆荚。在这个问题中,flutter 已经是稳定版本了。
        【解决方案5】:

        我的颤振安装是git clone --depth=1 所以我删除了整个目录:rm -rf flutter 然后git clone 再次。这次是完整的存储库。

        我认为它解决了这个问题。 pub get 再次工作,flutter 可以构建/运行。

        【讨论】:

          【解决方案6】:

          flutter 工具根据您本地 Flutter Git 存储库中的 Git 标签确定 Flutter SDK 版本。如果您创建了一个浅层 Git 克隆(即,使用了类似 git clone --depth=... 或对丢失标记信息的 Git 存储库进行其他操作,flutter 工具将无法确定版本号并报告 @987654324 @。

          【讨论】:

            【解决方案7】:

            转到flutter_image_cropper包的github page,在你的空间中fork它,然后在它的pubspec.yaml文件中更改它的sdk要求,提交它,推送它,现在在你的项目中,在导入这个包时,提供你的路径指向以 .git 结尾的分叉存储库的 github 链接。它会完美运行。

            您也可以参考Github page 了解常见问题

            【讨论】:

            • 感谢乌代的回答。如果我只是从 pubspecs 文件中删除 Cropper 插件,那么它也会出错。似乎在我重新启动笔记本电脑后发生了一些事情。可能是路径变量或不知道的东西。
            • @Ironic 参考常见问题页面的问题
            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2022-08-03
            • 2022-11-15
            • 2019-01-27
            • 1970-01-01
            • 2020-09-28
            • 2018-05-30
            • 2021-10-21
            相关资源
            最近更新 更多