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...
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.
This question is related to
android-studio
dart
flutter
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.
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.
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.
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
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
In case other answers didn't work for you
If you are using *nixOS or Mac
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.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
Language & Frameworks choose Flutter
and find Flutter SDK path
field.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.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
Perhaps you can try to sync up the dependencies by executing 'flutter pub get' in terminal.
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
In fact, it's a good habit to check your settings before you run the app.
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
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.
Flutter is usually installed(per illustrations) in.
C:\src\Flutter
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
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.
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.
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.
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.
which flutter
output PATH_TO_FLUTTER/bin/flutter
you ONLY NEED the PATH_TO_FLUTTER
so remove everything from /bin...
Flutter SDK path
input and apply.That will then ask you to restart IntelliJ and you should get both Flutter and Dart configured:
Good luck!
Many answers here, but I believe most are missing the point.
You're running this command from a shell, and most if not all answers are related to running inside an IDE. There's a difference.
If you're using the shell to run your Dart / Flutter commands, make sure you've set up the environment variables necessary for the commands to know where to look for the right tools.
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, so I have to tell the system where I've placed the various components.
Same goes for running commands from the command line vs. from an IDE, as an IDE can store this configuration, while the shell will not, unless you store it in the shell's startup files.
I use macOS, Homebrew and the ZShell, and I like to have the Dart SDK as a separate install, so I can track the DEV branch for Dart via Homebrew, while my Flutter install is using the BETA branch.
So, in my ~/.zprofile
I have:
export HOMEBREW_PREFIX="$(brew --prefix)"
# Android / Java, Dart / Flutter related
export FLUTTER_ROOT="${SSD}/Lib/flutter" # Path to your main Flutter install
export DART_SDK="${HOMEBREW_PREFIX}/opt/dart/libexec" # Separate Dart SDK install
export JAVA_HOME="/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home" # JDK
export ANDROID_SDK_ROOT="${SSD}/Lib/android/sdk" # Top-level Android SDK directory
export ANDROID_HOME="${SSD}/Lib/android/sdk" # Same as above, needed by other tools I use
export ANDROID_AVD_HOME="${SSD}/Lib/android/avd" # Path to the moved emulators etc
Then I make sure that the $PATH
variable is set up in the right order, so when I do Dart specific commands, the up-to-date Dart DEV branch is being used, while Flutter commands will use the Flutter BETA branch.
If you're using Zsh or Bash, add the additional paths at the end of .zshrc or .bashrc respectively, as these are called for every Terminal / Shell you start after login:
# Prepending to already established PATH
export PATH="\
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin:\
${HOME}/.pub-cache/bin:\
${HOMEBREW_PREFIX}/opt/dart/libexec/bin:\
${SSD}/Lib/flutter/.pub-cache/bin:\
${SSD}/Lib/flutter/bin:\
${SSD}/Lib/android/sdk/platform-tools:\
${SSD}/Lib/android/sdk/tools/bin:\
${SSD}/Lib/android/sdk/emulator:\
${PATH}"
# If you're using Zsh, add this to clean up duplicate entries building up from running this
# in every Terminal you launch:
# Remove duplicates from $PATH
typeset -aU path;
# Not sure, but in Bash, to remove duplicates you could do something like:
echo -n $PATH | awk -v RS=: '!($0 in a) {a[$0]; printf("%s%s", length(a) > 1 ? ":" : "", $0)}'
Now, that was a mouthful of stuff, but this is the way I maintain the order of operations...
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.
It usually happens with projects that were created in other machines. To fix this on Android Studio 3.1.3:
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.
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.
File/Settings
or Ctrl+Alt+S
to bring up the settings window.Language & Frameworks
and click on DartEnable Dart support for the project 'YOUR_PROJECT_NAME'
Dart SDK path:
enter the location where you are storing the flutter
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.
Downloading and Configuring the Dart SDK
If you don’t already have the Dart SDK, install it. You can get it either by itself or by downloading the Flutter SDK, which (as of Flutter 1.21) includes the full Dart SDK.
Choose one:
Here’s one way to configure Dart support:
Start the IDE, and install the Dart
plugin. To find the Dart plugin
,
from the Welcome screen choose Configure > Plugins
, then click
Install JetBrains plugin
, and then search or scroll down until you
find Dart. Once you've installed the Dart plugin, restart the IDE.
Create a new Dart project:
Create New Projec
t.Dart
.If you don't see a value for the Dart SDK
path, enter it.
<dart installation directory>/dart/dart-sdk
.Solved mine on macOS by clicking on
If not download flutter from this link
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!!!!!
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.
i solved it, try: click on open sdk settings and open flutter and then add sdk location when your download
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
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.
Source: Stackoverflow.com