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:
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.
Comments