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

  android, dart, flutter, gradle, sdk

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:srcflutterSDKflutterpackagesflutter_toolsgradleflutter.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:srcflutterSDKflutter
    • 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:UsersBarfi NandetiAppDataLocalAndroidsdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: C:Program FilesAndroidAndroid Studiojrebinjava
    • 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 FilesGoogleChromeApplicationchrome.exe

[√] Android Studio (version 2020.3)
    • Android Studio at C:Program FilesAndroidAndroid 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:UsersBarfi NandetiAppDataLocalProgramsMicrosoft 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!

Source: Android Questions

LEAVE A COMMENT