59

I got this error when I try to generate a signed apk in the android studio of my flutter app - Process 'command 'E:\Flutter Apps\flutter\bin\flutter.bat'' finished with non-zero exit value 1

I am able to run the app in both emulator and on my device but this error shows up only when I try to build a signed apk.

flutter doctor
[√] Flutter (Channel dev, v1.2.0, on Microsoft Windows [Version 10.0.17763.253], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.3)
[√] VS Code (version 1.30.2)
[√] Connected device (1 available)

• No issues found!

Any way to fix this?

Tried flutter clean

android studio Build > clean project and rebuild project(same error)

I am doing Build > Generated signed apk > apk > release > V1(Jar signature) > Finish to build the app

1
  • I was missing a semicolon in my dart code... Commented Apr 7, 2021 at 16:39

25 Answers 25

61

I had the same problem after this command flutter upgrade and upgrading from V 1.22 to V 1.27.
Exactly what I did, I went to pubspec.yaml then pub-get & pub-upgrde I found there's many outdated packages then I tried pub-outdated and the AS failed to upgrade it, the it's suggests to me to run this command flutter pub upgrade --major-versions and I saw that it's successfully downloaded and installed outdated packages, Then I do Invalided Caches & restarted AS because I found it's cached about 5GB on C partition, and finally I run the app normally again without any problems.

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

1 Comment

I've already fixed it using other approaches. It depends on what changes were made before that issue arose. One thing is for sure: it is usually because of the deprecated usage of the packages or source code. So, most of the time, adjusting the versions of the environment tools is the way to fix it.
25
  • check if you have any assets is not founded by pubspec.yaml maybe for typo you will get Waring for that after packages get

  • check AndroidX compatibilities in this Flutter app for help show this

3 Comments

Yes, I was assets name problem, now it's working fine
Yes, that was my issue it was " - assets/icons/svg" i added the '/" at the end like this " - assets/icons/svg/" and it works thanks
My issue was related to Assets folder of a native plugin I was developing. I just removed the reference from ppubspec.yaml and the problem's gone! Thank you!!
15

I solved that trouble with these steps :

  1. flutter clean
  2. delete folder ".gradle" in your projectdir>android>.gradle
  3. delete pubspec.lock
  4. update your gradle to 4.1.0 at projectdir>android>build.gradle
  5. update your gradle distributionUrl to 6.5.1 at projectdir>android>app>gradle>wrapper>gradle-wrapper.properties
  6. restart your IDE
  7. flutter pub get

after that several steps above, running flutter build or flutter run wouldn't be a problem anymore. sometimes step 4 n 5 are not necessary and still solved the problem.

Comments

12

For me this command solved:

flutter pub upgrade --major-versions

Comments

11

Hi Please check any error in your dart files thats may be cause during error while build

Comments

5

Flutter clean worked for me perfectly

Comments

5

You can try reconfiguring the Flutter SDK path in Android Studio's File | Settings | Languages ​​& Frameworks | Flutter.

I have just encountered the same problem and solved it successfully with this method.

1 Comment

how to reconfiguring the Flutte SDK? please help me
4

I encounter the same message and go to Android Studio's setting :

Language & Framework -> Flutter -> Tick "Enable Verbose logging" , and run the build again the check the actual root cause .

In my case the root cause is recursive path in android/build folder, I delete the build folder and problem solved.

Comments

3

stop the antivirus for some time if installed. it will work.

1 Comment

Yes, I whitelisted the android studio for deleting / modifying files/folders in Documents folder from antivirus software, and it started working
3

This solution solved my problem:

My android/build.gradle:

    buildscript {
    ext.kotlin_version = '1.4.21'
    repositories {
        jcenter()
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

Run flutter clean command in terminal. And delete build folder from android/app path.

Then run your project successfully.

Comments

2

In my case nothing worked. Then I deleted the flutter/bin/cache folder and in my command line I ran flutter command that downloads the Dart SDK. After download, setting up the flutter folder path in Flutter SDK Path in Android Studio -> Preferences -> Languages and Frameworks -> Flutter , then click Apply -> Ok, solves the error.

Comments

2

Check if any files in lib folder have

import 'dart.html';
import 'dart.io';

Remove them and try again

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
2

I just solved it! It has to deal with the "- assets/images/" line inside pubsec.yaml, I commented it and it works just fine!

Comments

2
  1. Go to your root directory of the flutter project by using the cmd command.

  2. write the command flutter clean, then from your android get dependencies to rebuild the cleaned.

if not solved, go to your pubspec.yaml and check your flutter asset indentation. eg

flutter:

  uses-material-design: true

  assets:

   - images/momo.jpg

it works for me absolutely.

Comments

1

You probably have errors in your code. Build in verbose mode using command flutter build apk --release -vv and check if there is any error.

Comments

1

I encountered the same problem. And I run "flutter clean" in the terminal. Then the answer was like this ".packages does not exist. Did you run "flutter pub get" in this directory?". When I run "flutter pub get", it solved my problem.

Comments

1

I had a problem with google-services.json file. Make sure that the file has the correct package name.

Comments

1

It's painful but another simple solution would be to reinstall flutter with the latest version and update the pubspec.yaml file with flutter pub upgrade --major-versions .

After that, perhaps, some code change would be necessary due to the pubspec dependances.

Comments

0

I had the same problem after this command flutter upgrade and upgrading from V 2.10.0 to V 3.0.0.

1.To fix this error, I went to C:\Users{username}\flutter.pub-cache\hosted and deleted the pub.dartlang.org folder.

2.After I executed flutter pub get command in my project. this command recreated the previously deleted folder with the packages inside

3.and I built my project again. the error has disappeared

Comments

0

In my case I was using Flutter module in native app and because of the syntax error in Flutter module (it could be any error, just look that you have no red-lined files) it wasn't able to compile

Comments

0

It mostly happens for android so In your project folder open the android folder on right clicking goto flutter -> open android module in Android Studio (in the Android module it is easy to understand the exception) try to upgrade what it recommends you and finally run the if the error is still there try to clean the project restart the IDE and run again it worked for me

Comments

0

.dart_tool folder delete and then run flutter build apk.

This process help me!

Comments

0

In my case, I have configured flavors in my application, and I was running the android.app.main module while writing native code. Instead of having a single main.dart file, I have different main.dart files for different flavors, such as main_dev.dart and main_prod.dart. After adding the main.dart file, everything is working fine.

Comments

0

if all solution not work open your terminal and run this code:

flutter run --verbose

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

./gradlew --stop solved issues for me

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.