Reputation: 4371
I installed Flutter and set up Android Studio. Then I cloned an example of flutter on GitHub (https://github.com/flutter/flutter) and launched it in Android Studio, but it warns me "Dart SDK is not configured", this happened to my co-worker as well. But if I create a new project in Android Studio, no problem at all.
What I have done:
Installed Flutter
Installed Android Studio, along with Flutter plugin including Dart plugin
Flutter run in command line works fine, all five tests passed. (See below)
[✓] Flutter (on Mac OS X 10.13.3 17D47, locale en-US, channel dev) • Flutter version 0.0.22 at /Users/katelyn/flutter • Framework revision 3001b3307d (7 days ago), 2018-01-30 11:37:15 -0800 • Engine revision 8f2d72b183 • Tools Dart version 2.0.0-dev.16.0 • Engine Dart version 2.0.0-edge.7af4db0ea091dddca6b2da851e6dda8d7f9467e8
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3) • Android SDK at /Users/katelyn/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-27, build-tools 27.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 9.2, Build version 9C40b • ios-deploy 1.9.2 • CocoaPods version 1.4.0
[✓] Android Studio (version 3.0) • Android Studio at /Applications/Android Studio.app/Contents • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
[✓] Connected devices • Android SDK built for x86 • emulator-5554 • android-x86 • Android 7.1.1 (API 25) (emulator)
Last week, I can run their example thru command line (in that dir),
flutter run
but now I it shows some errors with Gradle.
Launching lib/main.dart on Android SDK built for x86 in debug mode... Initializing gradle... 0.7s Resolving dependencies...
- Error running Gradle: Exit code 1 from: /Users/katelyn/AndroidStudioProjects/flutter/examples/flutter_gallery/android/gradlew app:properties:
FAILURE: Build failed with an exception.
Where: Build file '/Users/katelyn/AndroidStudioProjects/flutter/examples/flutter_gallery/android/app/build.gradle' line: 20
What went wrong: A problem occurred evaluating project ':app'. 3
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 0s
Please review your Gradle project setup in the android/ folder.
Upvotes: 436
Views: 537163
Reputation: 1049
In Android Studio
Tools > SDK Manager > Language & Frameworks > Flutter
Flutter SDK path:
choose the correct pathApply > OK
Upvotes: 5
Reputation: 5535
I had the same problem after importing a Flutter project from git. These are the steps to solve the problem.
This solved the issues for me.
Upvotes: 551
Reputation: 3326
In addition to the steps above (adding Dart and Flutter SDK path), this is what resolved the issue for me:
Follow through the steps guided on the popup until your repo displays properly:
Upvotes: 4
Reputation: 458
For the developers in 2024:
The error message "Dart SDK is not configured" along with the Gradle build failure suggests that there might be several things that could be wrong. Here’s how you can possibly resolve this issue:
1. Configure Dart SDK Ensure the Dart SDK is properly configured in your project settings.
Go to Preferences
> Languages & Frameworks
> Dart
in Android Studio.
Check Enable Dart support for the project
.
Ensure the Dart SDK path is correctly set (usually, it's inside the Flutter SDK directory, e.g., flutter/bin/cache/dart-sdk).
2. Check Flutter SDK Path Make sure that the Flutter SDK path is correctly set in your project.
Go to Preferences
> Languages & Frameworks
> Flutter
.
Set the Flutter SDK path correctly.
3. Update Flutter and Dart Plugins Ensure that the Flutter and Dart plugins in Android Studio are updated to the latest versions. Outdated plugins can sometimes cause issues.
4. Check for Flutter SDK Updates Run the following command to update the Flutter SDK:
flutter upgrade
5. Clean and Get Packages Run the following commands in the terminal from your project directory:
flutter clean
flutter pub get
android/gradle/wrapper/gradle-wrapper.properties
file and check the Gradle version. Make sure it is compatible with the Android Gradle plugin version.Ensure the Android Gradle plugin version is compatible with your Android Studio version. You might want to update it in your build.gradle
file.
You can also try invalidating the caches by going to File
> Invalidate Caches
/ Restart
in Android Studio.
Upvotes: 3
Reputation: 13
Search 'Flutter' in Android Studio.
Select 'Flutter' one with the logo.
Select 'Flutter Pub Get'.
Click on 'Yes,configure' button.
Write the path you want to save the file.
Click. 'OK' and it is done.
Upvotes: 0
Reputation: 1825
On macos:
After installing dart using brew install dart
, run brew info dart
At the bottom it prints:
Please note the path to the Dart SDK:
/usr/local/opt/dart/libexec
Upvotes: 3
Reputation: 165
For those who failed with the previous solutions.
Check whether your project's name is properly formated. In my case my project's folder was "app-2023", i closed android studio then renamed it to "app_2023" and everything works fine! You just have to enable the dart sdk support using the other solutions
Upvotes: 0
Reputation: 631
Most of the options above have shown how to configure Dart in the Windows System (If you have installed Dart and Flutter Doctor is showing all good).
On MacOS this option is available under Android Studio > Preferences ('Command' + ',')
Locate Languages and Frameworks / Dart
in the left pane.
Check Enable Dart Support
and locate the dart SDK. It will be inside your Flutter SDK Installation Directory '/flutter-installation-directory/flutter/bin/cache/dart-sdk'. Entering this will auto-populate the dart version in the row beneath, pointing that the framework is picked.
Check the box Enable Dart Support for the following modules
for your required project.
Click Apply. Click Ok.
As pointed above also, this should solve most of the use-cases. If error still persists, you can go File > Invalidate Caches/Restart
.
Upvotes: 45
Reputation: 354
In case if you getting Warning sign even after selecting the dart-sdk path in an existing project --
-- Close the Android Studio
-- Just delete the .dart_tool folder (mostly the first folder in your project)
-- Now Open the Android Studio and try to set the path like the techniques showed above--
File -> Settings -> Languages and Frameworks -> Dart
-- Now Enable the Check Box and set the dart-sdk path, now it will not show that warning.
And Your project will sync successfully.
Thank You
Upvotes: 12
Reputation: 21
I solved it, try:
Click on open SDK settings and open Flutter and then add SDK location when your download.
Upvotes: 0
Reputation: 1417
It may help to use the doctor with -v
flutter doctor -v
for me the result was as
...
Flutter version 2.0.5 at /usr/local/Caskroom/flutter/2.0.5/flutter
...
Then the dart path can be set as
/usr/local/Caskroom/flutter/2.0.5/flutter/bin/cache/dart-sdk
Upvotes: 35
Reputation: 2971
As of Flutter 1.21, the Flutter SDK includes the full Dart SDK. So if you have Flutter installed, you might not need to explicitly download the Dart SDK, unless:
Personally, as I mostly work on a laptop, I've offloaded my main drive from all the space required by the development tools, moving everything to an external drive as described in this answer
AFAIK, Dart is only dependent on having the $SDK/bin
directory available in your systems $PATH variable.
As for installing the SDK itself, both Dart and / or Flutter + Dart I find that downloading a .zip file of the channel (stable, beta or dev) you want, unzip it to a place on your hard-drive and include the path to the SDK /bin
directory early in the $PATH is the way to go.
As described in the Dart Documentation
Running commands from the command line is different from within an IDE (or other GUI app), as GUI apps usually store configuration in its own config files, while the various shells store its configuration in shell startup files using amongst other the $PATH variable to decide if it has knowledge of the given application / command. It also defines the order to look for the commands.
Unless the GUI app (IDE in this case) spawns a shell as part of its startup routine and gets the environment populated that way, these two configurations can be totally separate, and point to different tools / paths / utilities.
This would explain the scenario you mentioned:
But if I create a new project in Android Studio, no problem at all.
You can define the environment with the help of the shell's environment in Android Studio via
File -> New Projects Settings -> Settings For New Projects -> Tools -> Terminal
Here you can tell Android Studio which shell the IDE itself should take its environment from (as a path to your login shell of choice), define new variables and make sure the Shell Integration option is enabled.
Now you can have the same (or different if you wish) environments for running, say, pure Dart projects via the Command Line and for Flutter Apps running in the IDE, by picking the values you should already have defined in your shell startup file(s).
Note: Starting with Android Studio 4.2, the
ANDROID_SDK_HOME
environment variable is deprecated and has been replaced withANDROID_PREFS_ROOT
These things are subjects for change, so always check with the Android Studio configuration guide and the Android SDK Related part of the installation guide before setting these. It isn't always required, but is a good way for troubleshooting.
Upvotes: 2
Reputation: 183
In my case it was updating flutter sdk path in android studio, preferences.
Upvotes: 1
Reputation: 75
After installing Flutter, the best way to install Dart sdk is by creating a new project. In this window, click INSTALL SDK. This installs all necessary to work properly.
Upvotes: 1
Reputation: 1628
In my machine, flutter was installed in
C:\src\flutter
I set dart sdk path as
C:\src\flutter\bin\cache\dart-sdk
This solved my problem
Upvotes: 46
Reputation: 11
Perhaps you can try to sync up the dependencies by executing 'flutter pub get' in terminal.
Upvotes: -2
Reputation: 123
Solved mine on macOS by clicking on
If not download flutter from this link
Upvotes: 2
Reputation: 5993
for Mac,
Click on Android Studio,
then go to Preferences...
Set your Path inside DART SDK PATH here.
After Enable this for your project(like image show),then apply
Upvotes: 6
Reputation: 855
The reasons for this error can be either you did not install Flutter or you are using an older version of Flutter 1.21. So it is advisable to check the above things first of all. If none of the above things are the reasons for your error you can follow the below steps and it might help you.
Flutter SDK path should be empty here. The problem is in here
Upvotes: 2
Reputation: 12093
On Mac
After trying a bunch of stuff, and several times doing a fresh git clone
for the flutter project .. all to no avail, finally the only thing that worked was to download the MacOS .zip file and do a fresh install that way
https://flutter.dev/docs/get-started/install/macos
Upvotes: 1
Reputation: 1106
I followed the following steps to solve this problem:
First, Go to: File->Settings->Language & Framework->Flutter
There under the: 'flutter SDK path', put in the location where you have installed Flutter Mine was at: C:\src\flutter
Click Apply then OK and the android studio will refresh. The problem will be solved.
Upvotes: 14
Reputation: 1159
I had the same Dart SDK issue and I used this for my solution. To remedy the issue without having to use the terminal to test my programs each time the steps I followed are as follows.
flutter
SDK path. I did so by typing in echo $PATH
and finding the path with /flutter/bin..../flutter/bin
just add on /cache/dart-sdk/bin
making it .../flutter/bin/cache/dart-sdk/bin
..../flutter/bin/cache/dart-sdk/bin
is the location of your Dart SDK. Assuming you say the same Dart SDK is not configured error accompanied by something where you can configure your Dart SDK. You click the configure option and set .../flutter/bin/cache/dart-sdk
as your SDK. That should fix your problem. If not head over to the next step.Languages and Frameworks>Dart
.I went through these steps using IntelliJ IDEA so they should be pretty much the same. If that didn't work, sometimes making a dummy Dart project can get things working again. That fixed a similar issue for me.
Upvotes: 101
Reputation: 61
A quicker way..
Open up android studio..go the file menu....there u will find Invalidate caches/Restart..click it and respond to the pop up as Invalidate and Restart
Your android studio will get restarted.And its all done.
It really helped me.
Upvotes: 6
Reputation: 164
Just go to File > Settings > Languages & Frameworks > Dart
Click on check box Enable Dart Support for project 'projectName' Paste the Dart SDK path.
This is how you get Dart SDK path, follow the given steps copy the Dart SDK Path, which is in Flutter SDK, Go to location where your Flutter SDK Situated, then,
Flutter/bin/cache/dart-sdk , till dart-sdk, copy the path and paste it.
Upvotes: 4
Reputation: 1984
For mac:
Click Android Studio on top -> Click on Preferences -> Languages & Framework
-> Select Flutter
-> Browse Flutter SDK Path you have download link ["https://flutter.dev/docs/get-started/install/macos"]
-> Click OK ENJOY!!!!!
Upvotes: 10
Reputation: 1558
I recently faced this issue on my MAC device when I was running flutter project on Android Studio
Steps to fix this.
brew tap dart-lang/dart
brew install dart
brew info dart
Please note the path to the Dart SDK:/usr/local/opt/dart/libexec
paste the Dart SDK path in Android Studio Settings
Upvotes: 9
Reputation: 994
It normally happens when you are download projects from the github. normally dark sdk contains inside flutter.
you can solve this issue following these few steps
C:\flutter\bin\cache\dart-sdk
Upvotes: 18
Reputation: 22437
In my case Dart also installed separately for dart development with latest. So when IntelliJ suggest me to configure dart, I hit it and then it pointed to C:/tools/dart
that was the case.
So, I had to go to File->Settings->Language & Framework->dart
and add the SDK path to my Flutter sdk path with Dart SDK C:\flutter\bin\cache\dart-sdk
.
Note that as others mentioned if you pointed out the Flutter SDK path, you may not be needed to setup Dart SDK path because of Flutter SDK comes with Dart SDK in it.
Upvotes: 3
Reputation: 31246
Run this command:
$ echo "$(dirname $(which flutter))/cache/dart-sdk"
You'll get something like:
/home/lex/opt/flutter/bin/cache/dart-sdk
Enter that value as your Dart SDK path.
Upvotes: 5