-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[Bug]: Capacitor 7 is using JDK 21 for building android #7839
Comments
For reference also: AndroidIDEOfficial/AndroidIDE#1800 (comment) It seems to be a widespread misconception. If you do a quick google for Android JDK 21 errors you get tons of results (not necessarily Capacitor related). All of which can be resolved by downgrading to JDK 17 |
In the changelog of Android 15 they make an explicit mention about JDK 17: https://developer.android.com/about/versions/15/features#core-libraries
Further confirming that JDK 21 support is just a coincidence at times |
Android Studio Ladybug was shipped with JDK 21 and it was causing issues on projects configured to use JDK 17, so we updated Capacitor to use JDK 21 and made the usage of Ladybug a requirement for Capacitor 7. If it wasn't compatible I don't think they would be releasing Android Studio with an unsupported JDK version. We also updated gradle to 8.11, which should be compatible with JAVA up to 23. |
Gradle x Android compatibility goes up to Android Gradle Plugin v8.7 (https://docs.gradle.org/current/userguide/compatibility.html#android)
According to the release notes the minimum (and default) version of Gradle for Android Gradle Plugin v8.7 is 8.9 (https://developer.android.com/build/releases/past-releases/agp-8-7-0-release-notes#compatibility) The minimum and default JDK version for Android Gradle Plugin v8.7 is set to JDK 17 https://developer.android.com/build/releases/past-releases/agp-8-7-0-release-notes#compatibility Gradle 8.9 itself seems to supports up to Java 22. (https://docs.gradle.org/current/userguide/compatibility.html#java_runtime) I cannot find anywhere that the Android Gradle Plugin is compatible with JDK 21. Only either explicit or vague mentions that it supports JDK 17: https://developer.android.com/build/jdks and https://developer.android.com/about/versions/15/features#core-libraries I doubt that the Android team actually either intends everyone to compile their app using JDK 21 or for everyone to make their plugins/sdks support JDK 21. I'm not working for the Android team however, so it would probably be best to ask them for advise. Anyhow, the Gradle ecosystem is quite confusing and the documentation lacks pretty hard at this point |
Scott Stanchfield claims to have written the docs about the JDK versioning. He answers the following on SO: https://stackoverflow.com/a/77109376/8634342
|
Capacitor Version
Latest Dependencies:
@capacitor/cli: 7.0.1
@capacitor/core: 7.0.1
@capacitor/android: 7.0.1
@capacitor/ios: 7.0.1
Installed Dependencies:
@capacitor/android: 7.0.1
@capacitor/cli: 7.0.1
@capacitor/ios: 7.0.1
@capacitor/core: 7.0.1
Platforms Affected
Current Behavior
I just had a discussion with the maintainer of a Capacitor community package (see here capacitor-community/safe-area#43) who believes that Android does not support JDK 21 and only supports up to JDK 17. Because of this, I am unable to use this plugin. After a quick search, I came across https://developer.android.com/build/jdks which confirms that JDK 17 is used throughout.
Why does the latest version of Capacitor require JDK 21? Is it officially supported?
Expected Behavior
I am not sure, but imo Capacitor should use
instead of 21
Answer of the capacitor-community plugin member:
@tafelnl
The text was updated successfully, but these errors were encountered: