Reputation: 3986
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.
Upvotes: 16
Views: 33513
Reputation: 535
I spent half the day trying to fix this, and then figured out the right way to do this:
//navigate to your flutter SDK repo
cd C:\Development\flutter
//now check your current git remote
git remote -v
// the above is probably empty - unlike what's suggested by most others - its a simple fix
//replace by doing this
git remote add origin https://github.com/flutter/flutter.git
//then check the addition
git remote -v
// This should now say something like this:
origin https://github.com/flutter/flutter.git (fetch)
origin https://github.com/flutter/flutter.git (push)
// Now, this is the most important step, you must take it back to a clean state or this will happen again. So run:
git fetch origin
git reset --hard origin/master
// Now run flutter doctor and check what happened
flutter doctor
Upvotes: 0
Reputation: 878
What worked for me was running flutter pub cache clean
. Your mileage may vary, though.
Upvotes: 0
Reputation: 444
I had the same error and after spending much time found that it is because not set the command line path correctly.
just run this on the terminal in Android studio.
sudo xcode-select -switch /Library/Developer/CommandLineTools
Upvotes: 3
Reputation: 425
for me its due to different issue. Where i should run flutter as normal user not admin. hope this helps.
Upvotes: 0
Reputation: 464
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
Upvotes: 1
Reputation: 151
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
Upvotes: 5
Reputation: 1
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!!!
Upvotes: 0
Reputation: 90015
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).
Upvotes: 1
Reputation: 961
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.
Upvotes: 1
Reputation: 939
Upvotes: 5
Reputation: 6393
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
Upvotes: 3
Reputation: 1
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 :( )
Upvotes: 0
Reputation: 93
Try running flutter doctor if it still shows the flutter version is 0.0.0-unknown, Then mostly your flutter installation is corrupted. Please follow the steps mentioned in the below link. https://github.com/flutter/flutter/wiki/Workarounds-for-common-issues#flutter-installation-corrupted
Upvotes: 0
Reputation: 1148
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
Upvotes: -3