Use the FlutterFever JDK compatibility guide to compare runtime selection. Match its guidance to your actual Gradle and Android Gradle Plugin versions.
Symptom
The build reports an unsupported class-file version, a required Java version or an incompatibility between Java and Gradle. These messages concern the Android build toolchain, even when the Dart app is valid.
Collect the actual version tuple
Record the Flutter-selected Java runtime from doctor output, the system java -version result, the Gradle wrapper version and the Android Gradle Plugin version in the project. They can differ from the Java runtime selected inside Android Studio.
Choose a compatible combination
Check the current Gradle Java compatibility matrix and the requirements for the project’s selected Android Gradle Plugin. Do not choose the newest JDK independently of those constraints. A release-specific requirement may differ from an older tutorial.
Change one selection deliberately
Point the relevant build tool at the compatible runtime or update the wrapper/plugin combination as a reviewed migration. Keep related configuration changes together in version control. Kotlin DSL and Groovy projects use different syntax; edit the actual files your project contains.
Avoid cache deletion as the first action
A cache reset does not make an unsupported Java/Gradle pair compatible. Establish the version relationship first, then rebuild and inspect the new output.
Worked example
These commands run from a local project terminal.
flutter doctor -v
java -version
# From the android directory, use the wrapper for your OS:
# Windows: gradlew.bat --version
# macOS/Linux: ./gradlew --version
Read the result
Apply only the change that matches the observed cause. Keep the original diagnostic output so you can compare the same command after the change.
Make the runtime selection observable
Record the Java path shown by Flutter and the Java runtime shown by the Gradle wrapper. If a compatible JDK is already installed but the wrong one is selected, selecting the intended runtime can be a smaller change than upgrading every build component.
Flutter supports configuring a JDK directory through flutter config –jdk-dir with the actual verified installation path. Check the project’s required version combination first, then verify the selected path through doctor output and the original failing build. Use Android setup for the surrounding environment steps.
Practice and verification
Verify that the same runtime and wrapper are used by the editor and terminal. Run the failing build again. If it reaches a new failure, diagnose that new underlying error instead of continuing to upgrade unrelated components.