Skip to content
Latchkey

Flutter "Gradle task assembleDebug failed" in CI

Flutter’s assembleDebug is a thin wrapper over the Android Gradle build. When it "failed with exit code 1", the real error is in the Gradle output above - a dependency, SDK, or manifest problem in the Android layer.

What this error means

A flutter build apk or flutter run ends with "Gradle task assembleDebug failed with exit code 1". The headline is generic; the actionable error (e.g. an unresolved dependency or a missing SDK) appears earlier in the Gradle log.

Flutter output
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

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

Common causes

An underlying Android/Gradle error

The exit-code-1 line only says the Gradle build failed. The cause - a version mismatch, missing SDK, or manifest conflict - is in the Gradle output above it.

Toolchain or SDK mismatch

A wrong JDK, an Android Gradle Plugin / Gradle version mismatch, or a missing Android SDK component on the runner makes the Android build fail under Flutter.

How to fix it

Run the Android build with full stacktrace

Get the real Gradle error rather than the wrapper message.

Terminal
flutter build apk --debug -v
# or run Gradle directly for the full trace
cd android && ./gradlew assembleDebug --stacktrace --info

Align the toolchain

  1. Use the JDK version the Android Gradle Plugin requires (JDK 17 for AGP 8.x).
  2. Match the Gradle wrapper version to the AGP version.
  3. Install the needed Android SDK platforms/build-tools on the runner.

Clean and re-fetch when state is stale

Terminal
flutter clean
flutter pub get
flutter build apk --debug

How to prevent it

  • Pin Flutter, JDK, AGP, and Gradle versions together in CI.
  • Read the Gradle output above the wrapper line, not just the exit code.
  • Cache the Gradle and pub caches keyed on your lockfiles.

Related guides

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