Flutter: Exception: Gradle task assembleDebug failed with exit code 1
flutter run / flutter build apk stopped because the Gradle build failed; the real cause is printed above this line.
Gradle task assembleDebug failed with exit code 1Exception: Gradle task assembleDebug failed with exit code 1Gradle task assembleRelease failed with exit code 1Gradle build failed to produce an .apk fileError: Gradle task assembleDebug failed with exit code 1 Meaning
This line only reports that Gradle failed. Scroll up to the first "FAILURE: Build failed with an exception" and "What went wrong" block, or rerun with flutter run -v / ./gradlew assembleDebug --stacktrace in android/ for the full trace. Typical causes are SDK/JDK/plugin version mismatches, missing licenses, network problems downloading dependencies, or Kotlin/AGP version conflicts.
Common causes
- JDK/Gradle/AGP version mismatch
- compileSdk or minSdk conflicts
- Missing Android licenses or SDK components
- Network or proxy blocking dependency download
- Kotlin version incompatible with plugins
⚡ Quick fix
- Read the "What went wrong" block above this line
- Run
cd android && ./gradlew assembleDebug --stacktrace - Run
flutter clean, thenflutter pub get, then rebuild
Detailed fix by platform
Flutter
flutter run -v 2>&1 | tee build.logthen search the log for "What went wrong"
How to diagnose
- Cause — What went wrong block?
- Versions — JDK, Gradle, AGP aligned?
- Network — Dependencies downloadable?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Android license status unknown / licenses not accepted flutter doctor: Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses
- Android resource linking failed AAPT: error: resource x (aka y) not found — Android resource linking failed
- android:attr/lStar not found AAPT: error: resource android:attr/lStar not found
Most viewed in Flutter / Dart
- setState() called after dispose() Flutter: setState() called after dispose(): _MyState#1a2b3 (lifecycle state: defunct, not mounted)
- A RenderFlex overflowed Flutter: A RenderFlex overflowed by x pixels on the right/bottom
- Null check operator used on a null value Dart/Flutter: Null check operator used on a null value
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026