29

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

3
  • Did you find any solution for this issue, I also get the same issue :-( Commented Mar 22, 2021 at 6:49
  • @PulsaraSandeepa checkout my answer. I Just found a solution to this issue. Commented Mar 31, 2021 at 13:30
  • 1
    see stackoverflow.com/a/70140796/11675817 Commented Nov 28, 2021 at 5:08

20 Answers 20

22

The solution that worked for me was:

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

And it worked.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

4

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.

Comments

3

(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

Comments

2

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

1 Comment

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.
2

1 Comment

@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.
2

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

Comments

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

Comments

1

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

Comments

1

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

Comments

1

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

Comments

1

I have wrestled with this thing for some time. The issue is most likely due to a Gradle update. You need to update Gradle on your Flutter project as well.

You might also need to update you Target, Compile Version SDK and Kotlin version just to rule that out.

  1. Go to android/app/build.gradle and update the Gradle classPath as below

classpath 'com.android.tools.build:gradle:7.1.2'

  1. Go to android/app/gradle-wrapper.properties

distributionUrl=https://services.gradle.org/distributions/gradle-7.4-all.zip

Once done, run flutter.

Battle won, but the war with Gradle continues, until next time.

Comments

1

After I upgraded to Android Sdk 31, this happened to me. What solved was the answer suggested by @Elias Fazel above but before doing that, I first needed to edit my gradle.properties file. I 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, and then it worked.

android:exported=true

Comments

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.

Comments

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.

Comments

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 .

Comments

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.

Comments

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.

Comments

0

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

Comments

-1

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

and problem solved.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.