Fix Guide

Gradle Task assembleDebug Failed With Exit Code 1: How to Fix It in Flutter

RS
Raiyan Shahid Building ExamAI, FileForge, CodeCompiler & Party Rush under BrynFlow · Get in touch

Quick fix: "Gradle task assembleDebug failed with exit code 1" is a summary, not the real error. Scroll up to the first What went wrong block, or run flutter run -v. Then try flutter clean and flutter pub get. If the log mentions Java, "Unsupported class file major version", AGP, Kotlin or minSdk, jump to the matching step below. Most cases after a Flutter upgrade are version mismatches between Java, Gradle and the Android Gradle Plugin.

Type "flutter error" into Google and "flutter error gradle task assembledebug failed with exit code 1" is one of the first suggestions. Related searches include the same phrase with "android studio", "vscode flutter", "exit code 143" and "exit code 130", and people are also typing "gradle error invalid source release 21" and "flutter gradle 9". The timing is not random: Flutter 3.50, released on November 11, 2026, moved new projects to Android Gradle Plugin 9.3.1 and Gradle 9.5.0, so many developers are upgrading Android build files this month. This guide explains why Gradle task assembleDebug failed with exit code 1 appears and fixes it in order, from the quickest checks to the most involved.

Why "Gradle task assembleDebug failed" happens

When you press Run or type flutter run, Flutter asks Gradle to build a debug APK with the assembleDebug task. If anything in that Android build fails, Flutter prints this one line. The most common real causes are:

How to fix Gradle task assembleDebug failed with exit code 1

Work through these steps in order and rebuild after each one.

  1. Read the real error first. Scroll up in the Run or terminal output to the first FAILURE: Build failed with an exception and the What went wrong lines under it. For more detail run flutter run -v, or build from Gradle directly:
    cd android
    ./gradlew assembleDebug --stacktrace
    On Windows use gradlew.bat assembleDebug --stacktrace. The message there tells you which of the steps below applies.
  2. Clean and fetch packages. Stale build output is common after switching branches or upgrading Flutter:
    flutter clean
    flutter pub get
    flutter run
  3. Run flutter doctor and accept Android licenses. flutter doctor -v shows problems with the Android toolchain and, as Flutter's docs note, which Java version Flutter uses. If licenses are not accepted, run flutter doctor --android-licenses and answer y to each prompt.
  4. Point Flutter at a compatible JDK. Errors such as "Unsupported class file major version 65" mean Java and Gradle do not match. Google's AGP 9.5 release notes list Java 17 as the minimum JDK, and Flutter 3.50 also requires Java 17 or newer for new projects. Flutter uses Android Studio's bundled JDK by default; to choose another one run:
    flutter config --jdk-dir=/path/to/jdk
    Then run flutter doctor -v again to confirm. On macOS, /usr/libexec/java_home -V lists installed JDKs.
  5. Update Gradle and the Android Gradle Plugin. The Gradle version lives in android/gradle/wrapper/gradle-wrapper.properties (the distributionUrl line) and the AGP version in the com.android.application plugin entry of android/settings.gradle or settings.gradle.kts. Upgrade the wrapper from the android folder:
    cd android
    ./gradlew wrapper --gradle-version=<version>
    Pick a Gradle version that your AGP version supports; Google publishes the minimum for each AGP release (AGP 9.5 needs Gradle 9.6.0, for example). In Android Studio you can also open the android folder and use Tools > AGP Upgrade Assistant. A quick comparison is to run flutter create for a throwaway project with your current Flutter version and copy its versions.
  6. Fix Kotlin plugin errors after moving to AGP 9. If the log points at kotlin-android or the Kotlin Gradle Plugin, follow Flutter's "Migrating Flutter Android projects to built-in Kotlin" guide. As a temporary workaround the guide documents this flag in android/gradle.properties, which keeps the legacy Kotlin plugin working while your plugins catch up:
    android.builtInKotlin=false
    Remove it once the app and all plugins are migrated, because the Flutter team warns that manual Kotlin plugin setups will fail under AGP 10.
  7. Fix minSdk and plugin version conflicts. Messages such as "uses-sdk:minSdkVersion 21 cannot be smaller than version 24 declared in library" mean a plugin needs a higher minimum. Set minSdk in android/app/build.gradle or build.gradle.kts to the number in the error. Then run flutter pub outdated and flutter pub upgrade so plugins are on versions that support your Flutter and AGP versions.
  8. Stop Gradle daemons and give Gradle more memory. "Exit code 143" means the process was terminated and "exit code 130" means it was interrupted (for example with Ctrl+C), so these are usually not code errors. Run ./gradlew --stop in the android folder, close other heavy apps, and if you see out-of-memory errors raise the heap in android/gradle.properties, for example org.gradle.jvmargs=-Xmx4G.

Related errors with the same fixes

"Gradle error invalid source release 21" means the build asks for Java 21 bytecode but runs on an older JDK, so step 4 applies. "Gradle sync failed" in Android Studio is usually the same version problem shown during sync instead of during a build. If the build succeeds but Android Studio cannot find your phone, see our "No target device found" fix guide.

If nothing works

Create a fresh project with flutter create test_app and run it. If the new project builds, the problem is in your project's Android files or a plugin, so compare settings.gradle, gradle-wrapper.properties and app/build.gradle with the new project. If even a new project fails, the problem is your Java, Android SDK or Flutter install; flutter doctor -v will point to it. Check the Flutter breaking changes page for your version, then search or file an issue on GitHub flutter/flutter with the output of flutter doctor -v and the full --stacktrace log.

Upgrading to the newest release? Read our Flutter 3.50 material_ui migration guide first, and if you are new to Flutter start with the free Flutter track.

Frequently asked questions

What does Gradle task assembleDebug failed with exit code 1 mean?

It means the Android build Flutter started with Gradle failed. The exit code itself is generic; the real reason is printed earlier in the log, usually under What went wrong.

How do I see the full Gradle error in Flutter?

Run flutter run -v, or open a terminal in the android folder and run ./gradlew assembleDebug --stacktrace. On Windows use gradlew.bat instead of ./gradlew.

What does Unsupported class file major version mean?

Your JDK is newer than the Gradle version in the project can handle, or older than it needs. Flutter's docs say major version 65 means the Java version is too new for that Gradle. Upgrade Gradle or point Flutter at a matching JDK.

Does flutter clean fix Gradle errors?

It fixes problems caused by stale build files, which is common after switching branches or upgrading Flutter. It will not fix version mismatches, so read the error if the build still fails.

What is exit code 143 or 130 in Gradle?

These come from the process being stopped rather than a build error. 143 usually means the Gradle process was terminated, often for memory, and 130 means it was interrupted, for example with Ctrl+C.

Sources and further reading

Last checked November 22, 2026 against docs.flutter.dev and developer.android.com. Exact version numbers change with every Flutter and AGP release, so confirm them on the linked pages.

Where to go next

Build fixed? Keep building

The free Flutter track takes you from your first widget to state, navigation and networking.

Start the Flutter Track