You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
encountered a build failure when running flutter build apk using Flutter 3.24.5 on macOS with Java 21. The error suggests an incompatibility between the Gradle version and Java 21: Unsupported class file major version 65
The issue seems to stem from Gradle not supporting Java 21 yet. Flutter defaults to using Gradle 8.1.1, which only supports Java versions up to 17. This causes builds to fail if Java 21 is installed and configured as the default Java version.
Expected fix
Gradle and Flutter should provide compatibility with Java 21, or a clear error message and documentation should direct users to downgrade Java or upgrade Gradle. It would be helpful if Flutter's flutter doctor command included a compatibility check for Java and Gradle versions.
Additional context
Provide any extra information about your setup:
Flutter Version: 3.24.5 (stable)
Dart Version: 3.5.4
OS: macOS 15.1.1 (arm64)
Java Version: OpenJDK 21.0.3
Gradle Version: 8.1.1 (default Flutter configuration)
The issue was resolved temporarily by downgrading Java to version 17 and upgrading Gradle to version 8.3.
I would like to fix this problem.
I will try and fix this problem on docs.flutter.dev.
The text was updated successfully, but these errors were encountered:
Page URL
https://docs.flutter.dev/release/breaking-changes/android-java-gradle-migration-guide/
Page source
https://github.com/flutter/website/tree/main/src/content/release/breaking-changes/android-java-gradle-migration-guide.md
Describe the problem
encountered a build failure when running flutter build apk using Flutter 3.24.5 on macOS with Java 21. The error suggests an incompatibility between the Gradle version and Java 21:
Unsupported class file major version 65
The issue seems to stem from Gradle not supporting Java 21 yet. Flutter defaults to using Gradle 8.1.1, which only supports Java versions up to 17. This causes builds to fail if Java 21 is installed and configured as the default Java version.
Expected fix
Gradle and Flutter should provide compatibility with Java 21, or a clear error message and documentation should direct users to downgrade Java or upgrade Gradle. It would be helpful if Flutter's flutter doctor command included a compatibility check for Java and Gradle versions.
Additional context
Provide any extra information about your setup:
Flutter Version: 3.24.5 (stable)
Dart Version: 3.5.4
OS: macOS 15.1.1 (arm64)
Java Version: OpenJDK 21.0.3
Gradle Version: 8.1.1 (default Flutter configuration)
The issue was resolved temporarily by downgrading Java to version 17 and upgrading Gradle to version 8.3.
I would like to fix this problem.
The text was updated successfully, but these errors were encountered: