26

FAILURE: Build failed with an exception.

  • Where:

Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991

  • What went wrong:

Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1

mehul mulchandani
  • 261
  • 1
  • 3
  • 3

19 Answers19

19

The solution that worked for me was:

  1. Delete pubspec.lock file
  2. Do flutter pub get
  3. Run the project

And it worked.

FMorschel
  • 799
  • 5
  • 18
Rohan Patil
  • 289
  • 2
  • 6
9

I was able to get around this by running with null safety turned off. See this article for details.

 dart --no-sound-null-safety run
 flutter run --no-sound-null-safety
Luciano
  • 1,119
  • 12
  • 18
3

Maybe this outdated but should help someone.

Yesterday I Just restarted my pc and got this issue. I tried to search for the solution to this problem but nothing works in my case.

Solution

Just delete your flutter folder (Flutter Source) and then reinstall it. Your problem will solve.

Ottoman Coder
  • 362
  • 3
  • 15
2
Lav Sharma
  • 327
  • 1
  • 5
  • 23
  • @TonnyBaw this may or may not work for everyone as in the github also it worked for few people. So, maybe you can try something else mentioned above by other users. – Lav Sharma May 01 '21 at 08:36
2

(In my case this error occurred after I upgrade Android Sdk to 31)

Go to AndroidManifest.xml and Set this to all Activities with

android:exported=true
Elias Fazel
  • 2,093
  • 16
  • 20
2

if you build apk with --obfuscate, don't forget add a dot to head of your --split-debug-info directory.

flutter build apk --obfuscate --split-debug-info=/projectfolder/debug

to

flutter build apk --obfuscate --split-debug-info=./debug

worked for me

1

Definitely, the problem is from ur Gradle settings. For me, when I got the error, the problem was from the app/build.gradle file. there, my minSdkVersion was set to 23, so I just changed it to 21 and the error was solved. I will suggest u check your targetSdkVersion is set to 29 and compileSdkVersion is 29. I hope this help you too

  • You have to set the targetSdkVersion to 30 because the Play Store won't allow you to upload any appbundle targeted with the version 29. – Néstor Mar 20 '22 at 15:32
1

In my case, I moved the project folder to D:, flutter clean, pub get and it runs

Kevin Montalvo
  • 751
  • 7
  • 5
0

I tried flutter clean, reinstalling SDK. Nothing worked. My folder name was not correct. It was mvvm,provider test I changed it to mvvm_provider_test. Then it worked.

Grigory Zhadko
  • 1,484
  • 1
  • 19
  • 33
0

This error happened when I added a certain plugin. It turned out that the plugin required a minSdkVersion of 18. After I changed that, I did a flutter clean and after that, flutter pub get. So from this, I believe if you just added a recent plugin before you started facing this issue you look through the documentation of that plugin for installation info.

Also, after I did the above I had to restart my pc.

maykhid
  • 129
  • 1
  • 10
0

In case you're using flutter in command-line, just add -v which will run any flutter command in verbose mode. This should show you the origin of an error.

Like for me I was building with --split-debug-info and the folder I chose did not exist

0

In my case, what worked for me was removing the pubspec.lock and then doing a flutter pub get in my vscode command console, being in my project. Then modify the android\app\build.gradle file. inside the file I had compileSdkVersion 30 and update to version 31, being as follows compileSdkVersion 31

0

Download new Flutter SDK and update flutter path in your project, And try again

Suhad Bin Zubair
  • 717
  • 7
  • 10
0

After i upgraded to Android Sdk 31, this came for me. What solved was the answer suggested by @Elias Fazel above but before doing that, i first needed to edit my gradle.properties file. Added the following line :-

org.gradle.jvmargs=-Xmx1536M --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED

This was suggested from here : How to fix the ''module java.base does not "opens java.io" to unnamed module '' error in Android Studio?

After this, i added this line to activity tag in AndroidManifest.xml & then it worked.

android:exported=true

Hope this helps.

0

In my case the issue was in Git I have shifted to another branch which was merged and that causes the issue . then checkout from the master to main problem solved .

0

For me, the problem was in my pubspec.yaml file. I made some changes to it got this error commented out those changes and now it works fine.

0

It's related with the Gradle, this issue comes when you have multiple Gradle versions in C:\Users\userName.gradle directory, the solution I made I deleted all directory files in .gradle directory, and restarted the IDE again with default gradle version who comes when you try to create the project at the first time (gradle-7.4-all.zip) this way works for me.

0

did face the same issue "flutter pub cache clean" - running this command solved my issue hope this becomes helpful

0

I did not find any solution so i did window again and all required software like flutter android studio etc.

and problem solved.

Muhammad Kashif
  • 253
  • 3
  • 6