When Running `flutter build apk`, Gradle Task `assembleRelease` Failed with Exit Code 1 and APK is Not Created

Android
2019-09-13 19:45 (5 years ago) ytyng

While developing an app with Flutter, there are no issues when debugging with Android Studio.

However, when running flutter build apk,

Gradle task assembleRelease failed with exit code 1

is displayed and no APK is created.

Referencing this StackOverflow article:

https://stackoverflow.com/questions/55750890/flutter-failed-to-compile-apk-finished-with-error-gradle-task-assembledebug-fa

Based on the steps outlined:

1. Open gradle-wrapper.properties,

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

and change

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

(downgrade)

2. Open build.gradle

dependencies {
classpath 'com.android.tools.build:gradle:3.6.0-alpha09'

and change

dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'

3. Run flutter clean and then re-run flutter build apk.

By doing this, you will be able to see the cause of the error.

In my case, the issue was due to using a library that was not compatible with AndroidX. I opened pubspec.yaml and upgraded to a compatible version to resolve the issue.

Once the problem is resolved, you can revert the downgraded changes mentioned above.

Current rating: 5

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011