Flutter: FAILURE: Build failed with an exception on Could not create task ':app:compileFlutterBuildDebug'. Must provide Flutter source directory

Viewed 3508

Recently I immigrated my project to a new system and rectified all the errors but I got an exception that says provide flutter source directory. I added the flutter SDK path and checked but I still couldn't solve the problem.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutterSDK\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 572

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Could not create task ':app:compileFlutterBuildDebug'.
      > Must provide Flutter source directory

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

I have run the Flutter doctor cmd and everything is fine

flutter doctor -v
[√] Flutter (Channel stable, 2.5.0, on Microsoft Windows [Version 10.0.19043.1165], locale en-IN)
    • Flutter version 2.5.0 at C:\src\flutterSDK\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cc385b4b8 (6 days ago), 2021-09-07 23:01:49 -0700
    • Engine revision f0826da7ef
    • Dart version 2.14.0

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\Barfi Nandeti\AppData\Local\Android\sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] VS Code (version 1.60.0)
    • VS Code at C:\Users\Barfi Nandeti\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.63
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 93.0.961.47

• No issues found!
1 Answers

This is probably because the flutter SDK is in a different directory than your old machine. Checkout this answer.

Related