Dart SDK is not configured

302,516

Solution 1

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.

Solution 2

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.

Solution 3

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.

Solution 4

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

Solution 5

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
Share:
302,516

Related videos on Youtube

Katelyn
Author by

Katelyn

Updated on December 26, 2021

Comments

  • Katelyn
    Katelyn over 2 years

    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.

    • Krunal
      Krunal about 6 years
      You can use Android Studio, open and run your flatter project. I just tested it successfuly in Android Studio
    • Krunal
      Krunal about 6 years
      Did you update anything in your projectSource > android > gradle.build
    • Jerin
      Jerin over 2 years
      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 installed
    • PosmaJan
      PosmaJan over 2 years
      I get this error too, then I open 'project structure', click the problems, then I fix all the error. Worked for me. !image here
    • varotariya vajsi
      varotariya vajsi over 2 years
      Go to settings->languages & frameworks -> flutter -> in sdk section find "Flutter SDK path" and past your flutter sdk path here
  • Ricardo Gonçalves
    Ricardo Gonçalves over 5 years
    Just to add a comment here, sometimes Android Studio find by itself the Dart SDK just clicking in "activate dart sdk" message.
  • Raymond Chenon
    Raymond Chenon about 5 years
    "bin/cache/dart-sdk" was the missing piece of information.
  • Avid Programmer
    Avid Programmer over 4 years
    Dart and chose the SDK location means - which path needs to selected
  • Sergio Pardo
    Sergio Pardo over 4 years
    I did everything to configure flutter and dart, the only thing missing was to close and reopen android studio to make it work
  • Sisir
    Sisir about 4 years
    But what the java SDK path has to do here?
  • Purvik Rana
    Purvik Rana about 4 years
    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.
  • s_khan92
    s_khan92 about 4 years
    There should be a small change: The path should be like this: /cache/dart-sdk without /bin in the end.
  • Lutaaya Huzaifah Idris
    Lutaaya Huzaifah Idris about 4 years
    This worked better, I just simply specifies flutter SDK and it resolved the Dart issue.
  • Yako
    Yako about 4 years
    and don't forget to select your project module before applying :)
  • Fellow7000
    Fellow7000 almost 4 years
    Worked for me on Mac after checkout from Github, thanks!
  • fucukur
    fucukur almost 4 years
    There is dart-sdk in the flutter file.No need to reload. tnx
  • Codedreamer
    Codedreamer almost 4 years
    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.
  • BNetz
    BNetz about 3 years
    Where to click "Packages Get" when I open the pubspec.yaml?
  • C. Sederqvist
    C. Sederqvist about 3 years
    That may work, but it is certainly not "the best way". Quite far from it.
  • Pete Alvin
    Pete Alvin almost 3 years
    Yeah, "Sync Project With Gradle Files" no longer exists in File menu on Android Studio 4.2.1.
  • Daniel
    Daniel over 2 years
    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.
  • Mike
    Mike over 2 years
    After you choose the dart-sdk, make sure you check the module that your project is in as well or it won't be applied
  • Jaimin Modi
    Jaimin Modi about 2 years
    also add how..?