Unknown operating system - flutter

While trying to run $ flutter upgrade on cmd, powershell and bash.
Result was:
Downloading Dart SDK from Flutter engine 540786dd51f112885a89792d678296b95e6622e5...
Unknown operating system. Cannot install Dart SDK.
Why it could not install Dart SDK.
Before the release of flutter 1.17 it was working well but now it couldn't install Dart SDK.

Related

I have updated flutter sdk version to 2.10.0 but in terminal error coming saying : current version is 2.8.0

i have updated the sdk version of flutter to 2.10.0 but still old version (2.8.0) is showing in terminal due to which i am unable to use google fonts in my app as the google fonts require sdk version >=2.10.0. I Have used these two commands to upgrade - flutter upgrade and flutter pub get
Check for version file in flutter SDK. Open the flutter SDK folder and open the version file. It use to have a version specified, also check for the flutter version in VS Code at the bottom bar. If both are 2.10.0, then just flutter clean the project and rebuild. IF 2.8.0 is still there, download 2.10.0 zip file and unzip and replace the flutter SDK path.
You would check your flutter's SDK version through the below command
flutter doctor -v
Once you type above command, the system will show you about the current config

dart sdk is not configured in macos

I already have dart sdk installed:
running dart --version gives me:
Dart SDK version: 2.17.6 (stable) (Tue Jul 12 12:54:37 2022 +0200) on "macos_arm64"
up until now I was using vscode but now I need to go back to android studio which gives me the following error on top of every dart file:
Dart sdk is not configured
N.B: This is not a fresh install. I have been using flutter and vscode in my mac for quite some time now
Try this in your Android Studio.
Preference
plugin
search for flutter from the market
install flutter and also make sure dart is install, you can confirm by searching for dart also.
restart you android studio after and you should be fine

How to change the current Dart SDK version?

I ran the following commands in my foo project:
iDecode#iDecodes-Mac foo % pub get
Resolving dependencies...
The current Dart SDK version is 2.7.2.
Because foo requires SDK version >=2.12.0 <3.0.0, version solving failed.
iDecode#iDecodes-Mac foo % flutter --version
Flutter 2.6.0-11.0.pre • channel dev
Tools • Dart 2.15.0 (build 2.15.0-116.0.dev)
My pubspec.yaml file has:
environment:
sdk: '>=2.12.0 <3.0.0'
As you can see my current Dart SDK version is set to 2.7.2, my project is targeting a min of 2.12.0 and Dart SDK installed on my machine is 2.15.0. So, how do I change the current Dart SDK version?
This is my ~/.zshrc file
export PATH=/flutter/bin:$PATH
export PATH=$PATH:/$HOME/Library/Android/sdk/platform-tools/
export PATH="$PATH:/$HOME/flutter/bin"
export PATH="$PATH":"$HOME/.pub-cache/bin"
export JAVA_HOME=$(/usr/libexec/java_home)
It seems like you installed Flutter/Dart SDK somewhere using Homebrew. Use which flutter and which dart to see the actual Flutter/Dart command that is taking effect. Once you find where your Dart SDK is you can use
brew uninstall dart
After this when you run which dart it will now point to where your Flutter SDK was installed.
You can also try this way:
Just download that specific flutter version from here. and just set the flutter version in your editor and try to run it will run that specific flutter version but make sure you can't run that with terminal commands. So you need to handle all commands from the Tools option.
set flutter version
Must Run commands from here
The dart version is related with flutter version, see which version is what you need here
https://docs.flutter.dev/development/tools/sdk/releases
Upgrade by running flutter upgrade [check it out here] (update dart sdk for flutter)
Flutter comes with dart by default. Suggestion is to delete old flutter, delete .zshrc and download the latest stable version 2.5.3 for your mac and then give path for it in your .zshrc. Other method is switch to flutter stable by running flutter channel stable and then give flutter upgrade command so it will catch all the stuff from git in you local machine and you'll be good to go.
Simply go to the location where Dart SDK is kept and delete that and install a new Dart SDK version from the official website which is
https://dart.dev/get-dart
I had that same issue
Resolving dependencies... (5.3s)
The current Dart SDK version is 2.17.0.
Because talk_to_me depends on browser >=0.3.1+1 which requires SDK version
<2.0.0, version solving failed
I think we need to uninstall dart and install the correct version
To uninstall dart:
sudo apt purge dart

Can't set Dart SDK in Android studio

Linux Mint 20.1
In my Flutter project.
I install Dart
https://dart.dev/get-dart
So the Dart location is here on my machine:
whereis dart
dart: /usr/bin/dart /usr/lib/dart
Nice.
Now I want to set this path in Android Studio.
As you can see I get error that Dart SDK not exist
Dart SDK with Flutter provided in flutter/bin directory. In your case, if you provide a valid Flutter SDK path to Flutter plugin, Android Studio automatically detects Dart SDK. If you want to set Dart SDK directly, use it from flutter/bin.

The current Flutter SDK version is 0.0.0-unknown

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.
First Restart your system.
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
Remove these two files from the existing flutter sdk location in your system(which you extracted earlier) and paste these files again.
Again open android studio and try again by clicking Get dependencies button.
Click on run application.
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
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
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
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!!!
for me its due to different issue. Where i should run flutter as normal user not admin. hope this helps.
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