how to solve Execution failed for task ':app:compileFlutterBuildDebug'

Solution 1:

Something that work for me is: Delete your pubspec.lock, and press 'Pub Get' in your pubspec.yaml, it'll regenerate pubspec.lock file again and should fix the problem.

Solution 2:

Go to pubspec.yaml file, try doing Packages get | Pub get, and then build the project again.

Hope this resolves!

Solution 3:

I faced the same error and further, I tried:

  1. flutter clean
  2. flutter pub get in the terminal, and the issue solved!

Solution 4:

Optimizing imports (Ctrl + Alt + O) in Android Studio solved the issue for me. Studio Screenshot