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:
- Java and Gradle do not match. Flutter's own migration guide describes "Unsupported class file major version" errors when the JDK is too new or too old for the project's Gradle.
- Old Gradle or Android Gradle Plugin (AGP) versions after upgrading Flutter, Android Studio or a plugin.
- Kotlin plugin setup that AGP 9 no longer accepts. AGP 9 uses built-in Kotlin by default, and Flutter's docs say apps that still apply the Kotlin Gradle Plugin fail to build without migrating.
- A plugin that needs a higher minSdk or a newer version.
- Stale build files, missing SDK licenses or a Gradle process that ran out of memory.
How to fix Gradle task assembleDebug failed with exit code 1
Work through these steps in order and rebuild after each one.
- Read the real error first. Scroll up in the Run or terminal output to the first
FAILURE: Build failed with an exceptionand the What went wrong lines under it. For more detail runflutter run -v, or build from Gradle directly:
On Windows usecd android ./gradlew assembleDebug --stacktracegradlew.bat assembleDebug --stacktrace. The message there tells you which of the steps below applies. - Clean and fetch packages. Stale build output is common after switching branches or upgrading Flutter:
flutter clean flutter pub get flutter run - Run flutter doctor and accept Android licenses.
flutter doctor -vshows problems with the Android toolchain and, as Flutter's docs note, which Java version Flutter uses. If licenses are not accepted, runflutter doctor --android-licensesand answeryto each prompt. - 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:
Then runflutter config --jdk-dir=/path/to/jdkflutter doctor -vagain to confirm. On macOS,/usr/libexec/java_home -Vlists installed JDKs. - Update Gradle and the Android Gradle Plugin. The Gradle version lives in
android/gradle/wrapper/gradle-wrapper.properties(thedistributionUrlline) and the AGP version in thecom.android.applicationplugin entry ofandroid/settings.gradleorsettings.gradle.kts. Upgrade the wrapper from theandroidfolder:
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 thecd android ./gradlew wrapper --gradle-version=<version>androidfolder and use Tools > AGP Upgrade Assistant. A quick comparison is to runflutter createfor a throwaway project with your current Flutter version and copy its versions. - Fix Kotlin plugin errors after moving to AGP 9. If the log points at
kotlin-androidor 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 inandroid/gradle.properties, which keeps the legacy Kotlin plugin working while your plugins catch up:
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.android.builtInKotlin=false - 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
minSdkinandroid/app/build.gradleorbuild.gradle.ktsto the number in the error. Then runflutter pub outdatedandflutter pub upgradeso plugins are on versions that support your Flutter and AGP versions. - 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 --stopin theandroidfolder, close other heavy apps, and if you see out-of-memory errors raise the heap inandroid/gradle.properties, for exampleorg.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
- Flutter docs: Android Java Gradle migration guide
- Flutter docs: Migrating Flutter Android projects to built-in Kotlin
- Flutter docs: Set up Android development
- Android Developers: Android Gradle Plugin release notes and compatibility
- Flutter blog: What's new in Flutter 3.50
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.