Dart SDK is not configured
Asked Answered
A

37

406

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:

  1. Installed Flutter

  2. Installed Android Studio, along with Flutter plugin including Dart plugin

  3. 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.

Allay answered 6/2, 2018 at 19:49 Comment(5)
You can use Android Studio, open and run your flatter project. I just tested it successfuly in Android StudioKerby
Did you update anything in your projectSource > android > gradle.buildKerby
Go to project settings (cmd + , in Mac & ctrl + , probably for Windows), under Languages & Frameworks, there should an option Dart, enable dart support if disabled and provide the path to where you have your dart installedCorson
I get this error too, then I open 'project structure', click the problems, then I fix all the error. Worked for me. !image herePluralism
Go to settings->languages & frameworks -> flutter -> in sdk section find "Flutter SDK path" and past your flutter sdk path hereNess
R
524

I had the same problem after importing a flutter project from git. These are the steps to solve the problem.

  1. File->Settings->Language & Framework->Flutter
  2. Choose flutter SDK path: the first time we install flutter, we choose the location where the flutter should be installed. Choose this location.
  3. Click OK and the android studio will refresh. Carry on if the problem is solved.
  4. If you are still stuck with the error.
  5. Goto this link and install Dart.
  6. Goto the same place in settings, ..Language & Framework->Dart and chose the SDK location.

This solved the issues for me.

Racket answered 6/4, 2018 at 2:42 Comment(5)
Dart and chose the SDK location means - which path needs to selectedDolley
All steps are perfect and still after that you're not able to solve then just open pubspec.yaml and click Packages Get. That will solve everything.Faddish
Where to click "Packages Get" when I open the pubspec.yaml?Gahnite
I get this error for our team developed projects and all I need to do is generally: File -> Invalidate Caches -> Invalidate & Restart (Assuming you are using Android Studio)Beguine
I come back to this answer every now and then. Thank you so muchLofton
K
348

It usually happens with projects that were created in other machines. To fix this on Android Studio 3.1.3:

  1. File-> Settings (ctrl+alt+s)
  2. Languages and Frameworks -> Dart
  3. Check "Enable Dart support for the project..."
  4. In "Dart SDK path" click in "..." and navigate to flutter SDK directory. Under that directory you'll find "bin/cache/dart-sdk". This is the dart sdk path you should use.
  5. Click "Apply"
  6. Close the project and open it again (sometimes you need this step, sometimes doesn't)

Edit 2019-05-28 - I don't know how long this option is enabled but I have noticed that in Android Studio 3.4 it's easier to Enable Dart Support in projects that were developed in other machines.

  1. File -> Sync Project With Gradle Files
  2. After it builds, click in "Enable dart support" in the top of editor panel.
Kati answered 27/7, 2018 at 12:40 Comment(10)
Just to add a comment here, sometimes Android Studio find by itself the Dart SDK just clicking in "activate dart sdk" message.Curling
"bin/cache/dart-sdk" was the missing piece of information.Illusionist
I did everything to configure flutter and dart, the only thing missing was to close and reopen android studio to make it workProtectionism
Worked for me on Mac after checkout from Github, thanks!Dratted
This answer should be the one top. The answer is direct and people who migrated their project to a new android studio application are likely to have error like this.Initiative
Yeah, "Sync Project With Gradle Files" no longer exists in File menu on Android Studio 4.2.1.Choice
After you choose the dart-sdk, make sure you check the module that your project is in as well or it won't be appliedHypnosis
"Close the project and open it again (sometimes you need this step, sometimes doesn't)" this part is crucial for mePraise
I only provide the Flutter path and the Dart path is automatically found by Android StudioLesterlesya
Alright so this was my issue as well. New install, everything OK but path for Flutter SDK was not automatically added in Android Studio. Setting this fixed Dart SDK issue.Deaf
M
92

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.

  1. Find flutter SDK path. I did so by typing in echo $PATH and finding the path with /flutter/bin.
  2. Assuming your path is something like .../flutter/bin just add on /cache/dart-sdk/bin making it .../flutter/bin/cache/dart-sdk/bin.
  3. This .../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.
  4. Open your Android Studio preferences(Command + ',') and go to Languages and Frameworks>Dart.
  5. Under the Dart menu, you should be able to enter your Dart SDK path.

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.

Mayence answered 12/3, 2018 at 3:41 Comment(2)
There should be a small change: The path should be like this: /cache/dart-sdk without /bin in the end.Troupe
I had Flutter installed and I tried to create a Dart Project in Intellij Idea, which resulted into an error. But after trying your solution regarding the path .../flutter/bin/cache/dart-sdk/bin it worked fine.Galligan
P
45

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

Piercing answered 11/1, 2021 at 10:41 Comment(1)
also add how..?Irreligion
B
39

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' + ',')

  1. Locate Languages and Frameworks / Dart in the left pane.

  2. 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.

  3. 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.

enter image description here

Bikaner answered 20/11, 2020 at 17:23 Comment(1)
My Preferences window doesn't have Languages and Frameworks for this particular projects. In other projects in which I already have Dart enabled it appears, but I can't enable for this one because it doesn't even appear.Tammeratammi
U
35

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
Unintelligible answered 23/4, 2021 at 15:42 Comment(0)
B
29

Flutter is usually installed(per illustrations) in.

C:\src\Flutter

For Windows Installations...

You can try running flutter doctor for installation issues. Also run flutter upgrade to get the latest version of Flutter and Dart SDKs.

DART SDK can be found at

/flutter/bin/cache/dart-sdk
Blocky answered 6/2, 2018 at 19:49 Comment(1)
This worked better, I just simply specifies flutter SDK and it resolved the Dart issue.Vintner
B
26

In case other answers didn't work for you

If you are using *nixOS or Mac

  1. Open the terminal and type which flutter. You'll get something like /Users/mac/development/flutter/bin/flutter under that directory go to cache folder here you will find either dart-sdk or (and) dart-sdk.old folder. Copy their paths.
  2. Open preferences by pressing ctrl+alt+s or cmd+, on mac. Under Language & Frameworks choose Dart find Dart SDK path. Put that path you've copied at first step to there. Click Apply.

If this didn't solve the issue you have to also set the Flutter SDK path

  1. Under Language & Frameworks choose Flutter and find Flutter SDK path field.
  2. Your flutter SDK path is two step above in the folder hierarchy relative to which which flutter command gave to you. Set it to the field you've found in step 1 of this header. Again click Apply & click save or ok.
Brisance answered 24/10, 2018 at 16:16 Comment(0)
S
21

I am using Win10 Pro;

If you are using Android Studio and getting this message 'Error: Dart SDK is not found in specified location',

My fix was this.

  1. Go to File/Settings or Ctrl+Alt+S to bring up the settings window.
  2. Go down to 'Language & Frameworks and click on Dart
  3. Check Enable Dart support for the project 'YOUR_PROJECT_NAME'
  4. For the Path Dart SDK path: enter the location where you are storing the flutter directory.
  5. Drill down that directory till you see the Dart SDK directory C:\flutter\bin\cache\dart-sdk. You can also Check SDK update by checking the box and clicking on Check now to get the latest version.

This worked for me.

Semitic answered 20/11, 2018 at 15:49 Comment(0)
D
18

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

  1. go to the setting using (Ctrl + Shift + s)
  2. go the the Languages & Framework
  3. go to Dart
  4. Enable Dark support for the project
  5. Change the dark sdk path C:\flutter\bin\cache\dart-sdk
  6. Apply
Davy answered 5/2, 2020 at 4:9 Comment(1)
and don't forget to select your project module before applying :)Lutz
T
14

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.

Tripe answered 12/8, 2020 at 18:5 Comment(0)
A
12

Goto preferences -> Languages & Frameworks -> Flutter

Set your flutter sdk path for example :- /Users/apple/flutter-sdk/flutter

then apply your settings.

Make sure all dependencies are installed. if not run - flutter pub get to install dependencies

Atropine answered 15/12, 2019 at 7:33 Comment(1)
Oddly enough this did it for me. When I opened the terminal I noticed the current directory was one up from the project root.Johnajohnath
M
12

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

Modesta answered 12/11, 2021 at 5:17 Comment(0)
C
10

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!!!!!

Chainman answered 2/3, 2020 at 3:2 Comment(0)
F
9

I recently faced this issue on my MAC device when I was running flutter project on Android Studio

Steps to fix this.

  1. install dart on MAC os using brew (https://dart.dev/get-dart)

brew tap dart-lang/dart

brew install dart

  1. run

brew info dart

  1. It will give you output something like this

Please note the path to the Dart SDK:/usr/local/opt/dart/libexec

paste the Dart SDK path in Android Studio Settings

Faris answered 18/2, 2020 at 11:57 Comment(0)
T
6

for Mac,

  1. Click on Android Studio,

  2. then go to Preferences...

  3. Set your Path inside DART SDK PATH here.

enter image description here

After Enable this for your project(like image show),then apply

Taam answered 6/11, 2020 at 13:23 Comment(0)
A
5

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.

Azalea answered 23/1, 2020 at 13:2 Comment(0)
O
5

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.

Overlie answered 26/6, 2020 at 0:46 Comment(0)
C
4

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.

Campania answered 16/6, 2020 at 12:3 Comment(1)
There is dart-sdk in the flutter file.No need to reload. tnxExterminate
E
3

OS: Ubuntu 19.04

IntelliJ: 2019.1.2RC

I have read on all the previous answer and after some time trying to get this working I found that the IntelliJ Flutter plugin does not want the path to which flutter instead it needs the base installation folder.

So the 2 steps which fixed:

  1. Install IntelliJ Flutter plugin:
    • Ctrl + Shift + a (Open Actions)
    • Type in search 'Flutter' hit enter Install and restart IntelliJ
  2. Configure Flutter Plugin:
    • Ctrl + Alt + s (Open Settings)
    • Type in search 'Flutter', Select option under Language & Frameworks
    • Open terminal which flutter output PATH_TO_FLUTTER/bin/flutter you ONLY NEED the PATH_TO_FLUTTER so remove everything from /bin...
    • Paste the location on the Flutter SDK path input and apply.

That will then ask you to restart IntelliJ and you should get both Flutter and Dart configured:

enter image description here

Good luck!

Executor answered 7/5, 2019 at 13:17 Comment(0)
T
3

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.

Therewithal answered 31/1, 2020 at 4:53 Comment(0)
T
3

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

Thunderclap answered 17/4, 2023 at 19:41 Comment(0)
Q
2

Revision of earlier answer to reflect new changes:

Changes since Flutter 1.21

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:

  • You don’t use Flutter.
  • You use a pre-1.21 version of Flutter.
  • You want to reduce disk space requirements
  • You want better separation between Dart SDK distribution channels / versions and the one bundled in the Flutter SDK.

Installing the Dart SDK

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

Easy Dart SDK Install

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

A Possible Problemo

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).

Android Studio Configuration

Note: Starting with Android Studio 4.2, the ANDROID_SDK_HOME environment variable is deprecated and has been replaced with ANDROID_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.

Quincy answered 4/6, 2020 at 20:45 Comment(0)
G
2

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.

  1. Go to File --> Settings
  2. Then Languages and Frameworks --> Flutter

Flutter SDK path should be empty here. The problem is in here

  1. Copy the Flutter SDK path
  2. Paste it in the empty text field
  3. Apply and OK
Granulose answered 19/10, 2020 at 3:9 Comment(0)
E
2

Solved mine on macOS by clicking on

If not download flutter from this link

Ectophyte answered 8/12, 2020 at 18:44 Comment(0)
E
2

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
  1. Resolve Gradle Issues Open the 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.

  1. Run the Project After performing the above steps, try running your project again.
Encyclical answered 26/10, 2023 at 23:22 Comment(0)
C
1

similar to above, I got the dart sdk path from a project I created with flutter(not cloned) by going to Android Studio Preferences | Languages & Frameworks | Dart. Then similarly in the cloned project go to Preferences | Languages & Frameworks | Dart and "Enable Dart support for the project..." and enter the path you saved.

Calvincalvina answered 29/3, 2019 at 10:32 Comment(0)
T
1

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

Taxi answered 17/9, 2020 at 22:59 Comment(0)
C
1

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.

Catling answered 7/2, 2021 at 10:5 Comment(1)
That may work, but it is certainly not "the best way". Quite far from it.Quincy
N
1

In my case it was updating flutter sdk path in android studio, preferences.

Norvan answered 4/3, 2021 at 9:13 Comment(0)
K
0

I solved it, try:

Click on open SDK settings and open Flutter and then add SDK location when your download.

Kienan answered 4/11, 2020 at 12:24 Comment(0)
C
0

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

Cartilage answered 3/4, 2023 at 14:16 Comment(0)
C
0

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.

Contraindicate answered 21/5, 2023 at 10:21 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Combatant
P
0

In addition to the steps above (adding Dart and Flutter SDK path), this is what resolved the issue for me:

  1. Tap on File > Repair IDE
    enter image description here

  2. Follow through the steps guided on the popup until your repo displays properly:

  • Tap on Rescan Project Indexes
    enter image description here
  • Tap on Reopen Project
    enter image description here
Phone answered 10/4 at 9:20 Comment(0)
D
-1

Go to File->Settings-> Language & Framework->Dart.

Demetricedemetris answered 22/9, 2023 at 18:58 Comment(0)
T
-2

Perhaps you can try to sync up the dependencies by executing 'flutter pub get' in terminal.

Tabbi answered 21/12, 2020 at 6:9 Comment(1)
You can specify more information how to do it. Thanks.Enantiomorph
P
-3

In fact, it's a good habit to check your settings before you run the app.

  1. Have you check the java SDK path ?(in fact, if you have already run another app but failed to run this, which might be download from Github or others.
  2. then you might have to check the flutter settings and the dart settings.
Phial answered 8/6, 2019 at 10:28 Comment(1)
But what the java SDK path has to do here?Grapefruit

© 2022 - 2024 — McMap. All rights reserved.