Short answer
Scroll up from the exit line to the first error, or run flutter run -v to see the full Gradle output. If it mentions Java or an unsupported class file version, run flutter doctor to see which Java is in use, and flutter analyze --suggestions from the project folder to check that Java, Gradle and the Android Gradle plugin fit together. If it points at a build file, run ./gradlew help in the android folder to check the build scripts on their own.
Find the real error, then fix it
01
The exit line is a wrapper
Flutter reports the Gradle task that failed, not why. The reason is a few lines above, after “What went wrong”. Run with -v for the whole log, or build from the android folder to see Gradle’s own output.
flutter run -v cd android ./gradlew assembleDebug02
Java and Gradle don’t match
“To find the Java version being used run flutter doctor.” Flutter, Android Java Gradle migration guide
An Unsupported class file major version error means Gradle is too old for the Java that builds the app. Check which Java Flutter uses first, then let Flutter check the versions. The full steps are on the class file version page linked below.
flutter doctor flutter analyze --suggestions03
JAVA_HOME points at the wrong place
“You must ensure that a Java Development Kit version 17 or higher is properly installed, the JAVA_HOME environment variable is set, and Java is added to your PATH.” Gradle, Troubleshooting builds
Gradle run directly, for example ./gradlew from the android folder or on a CI runner, uses JAVA_HOME. If the error says JAVA_HOME is set to an invalid directory, point it at an installed JDK. To choose the JDK Flutter itself uses, run flutter config --jdk-dir.
04
A build file is broken
“You can verify the problem with Gradle scripts by running gradle help, which executes configuration scripts but no Gradle tasks.” Gradle, Troubleshooting builds
A bad edit to build.gradle, settings.gradle or gradle.properties fails every build the same way, even when ./gradlew --version works. Run gradle help through the wrapper to check the scripts without building.
cd android ./gradlew help
Checked against the vendor’s docs on : Gradle User Manual: Troubleshooting builds; Flutter docs: Android Java Gradle migration guide.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way.See scope and start
Related: Flutter unsupported class file major version · Flutter MissingPluginException · Flutter pod install failed · Expo EAS Build failed