Skip to content
Latchkey

Flutter "Gradle task assembleRelease failed" (Android) in CI

flutter build apk --release runs the Android Gradle assembleRelease task. When it "failed with exit code 1", the real error - signing config, R8/ProGuard shrinking, or an unresolved dependency - is in the Gradle output printed above the wrapper line.

What this error means

A flutter build apk --release or flutter build appbundle job ends with "Gradle task assembleRelease failed with exit code 1". The headline is generic; the actionable line appears earlier in the Gradle log.

Flutter output
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lintVitalAnalyzeRelease'.

Running Gradle task 'assembleRelease'...
Gradle task assembleRelease failed with exit code 1

Common causes

An underlying release-only Gradle failure

Tasks that only run in release builds (R8 shrinking, lintVital, signing) fail, but Flutter reports only the wrapper exit code.

Missing or misconfigured signing for release

Release builds require a valid keystore and signingConfigs; a missing key or key.properties makes the release task fail where debug succeeds.

How to fix it

Run the Android release build with a stacktrace

Surface the real Gradle error instead of the wrapper message.

Terminal
flutter build apk --release -v
cd android && ./gradlew assembleRelease --stacktrace --info

Provide signing config from CI secrets

  1. Decode the keystore from a base64 secret into the runner.
  2. Write android/key.properties with the store/key passwords from secrets.
  3. Reference it from signingConfigs.release in app/build.gradle.
android/key.properties
storeFile=../app/upload-keystore.jks
storePassword=${{ secrets.STORE_PASSWORD }}
keyAlias=upload
keyPassword=${{ secrets.KEY_PASSWORD }}

How to prevent it

  • Pin Flutter, JDK, AGP, and Gradle versions together in CI.
  • Inject keystore and key.properties from secrets, never commit them.
  • Read the Gradle output above the wrapper line, not just the exit code.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →