For the developers in 2023:
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
- Resolve Gradle Issues
Open the
android/gradle/wrapper/gradle-wrapper.propertiesfile 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.
- Run the Project After performing the above steps, try running your project again.