Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility Between Flutter Build and Java 21 (Unsupported Class File Major Version 65) #11431

Open
1 task
aditya305 opened this issue Nov 23, 2024 · 1 comment
Labels
e1-hours Effort: < 8 hrs from.page-issue Reported in a reader-filed concern p1-high Major but not urgent concern: Resolve in months. Update each month.

Comments

@aditya305
Copy link

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.

  • I will try and fix this problem on docs.flutter.dev.
@aditya305 aditya305 added the from.page-issue Reported in a reader-filed concern label Nov 23, 2024
@sfshaza2
Copy link
Contributor

sfshaza2 commented Dec 4, 2024

Haven't confirmed yet.

@sfshaza2 sfshaza2 added p1-high Major but not urgent concern: Resolve in months. Update each month. e1-hours Effort: < 8 hrs labels Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e1-hours Effort: < 8 hrs from.page-issue Reported in a reader-filed concern p1-high Major but not urgent concern: Resolve in months. Update each month.
Projects
None yet
Development

No branches or pull requests

2 participants