The current Flutter SDK version is 0.0.0-unknown

Viewed 13604

I am not using GIT. As i have seen some posts/questions where users are mentioning they are using GIT and due to that they are getting the error.

Yesterday, I added Image Cropper Plugin and then I restarted the machine. After the restart, it starts giving the error.

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)

I run Flutter version command -> Below is the output.

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

I did Flutter Clean and Flutter Pub Get they both didn't fix the issue.

I run Flutter Doctor and here is the output.

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.

I am not using Xcode from the beginning.

Any advice on how to fix this issue.

Edit

I checked the path by running echo $PATH.

/Users/rahul/Desktop/flutter/bin

Path is also there.

Edit 2 Flutter Upgrade also didn't helped.

10 Answers

Flutter SDK files

  1. First Restart your system.
  2. Open your downloaded Flutter SDK zip folder (folder you get when you download flutter sdk from official website) and copy packed-refs and config file which is under <flutter_windows_1.22.5-stable.zip\flutter.git> folder
  3. Remove these two files from the existing flutter sdk location in your system(which you extracted earlier) and paste these files again.
  4. Again open android studio and try again by clicking Get dependencies button.
  5. Click on run application.
  6. App will run successfully.

for the new git version you need to config the path of your projet like this git config --global --add safe.directory D:/path_were_flutter_is_locate/flutter

if it happened to you on Mac OS just install homebrew like on the description on https://brew.sh

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

then install git

brew install git

Try running git checkout stable in your flutter installation folder. I had same issue in Windows and this fix works for me (Sorry if my english is bad :( )

my flutter installation was git clone --depth=1 so I removed the whole dir: rm -rf flutter then git clone once again. this time the full repository.

I think it solved the issue. pub get works again, and flutter can build/run.

The flutter tool determines the Flutter SDK version from the Git tags in your local Flutter Git repository. If you've created a shallow Git clone (i.e., used something like git clone --depth=... or done other manipulations to your Git repository that lost the tag information, the flutter tool will be unable to determine the version number and will report 0.0.0-unknown.

If you find yourself in this state, your best course of action would be to reinstall the Flutter SDK in a supported way (i.e., by following the installation instructions).

After uninstalling and reinstalling flutter you have to create a new flutter app using flutter create app-name. trying to work on the same project will not solve the issue.

This problem fed me up for days. How i solved this is issue is that i just upgraded the flutter and then deleted the current project while copying the code and created a new project and then pasted the code to the new project Hurray the issue was solved!!!

I faced this error because I have multiple user on my system so when i trying to run my project from not-admin user i get this error. i resolved it by using this command

git config --global --add safe.directory C:/flutter

"C:/flutter": is your flutter sdk folder path

Go to github page of flutter_image_cropper package, fork it in your space, then change its sdk requirement in its pubspec.yaml file, commit it, push it, now in your project, while importing this package, provide path of your github link to your forked repository ending with .git. It will work perfectly.

Also you can refer Github page for common issues

Related