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

com.google.maps.android:maps-ktx:5.1.0 requires Java 17 runtime #266

Closed
mateuszkwiecinski opened this issue Jul 4, 2024 · 6 comments · Fixed by #267
Closed

com.google.maps.android:maps-ktx:5.1.0 requires Java 17 runtime #266

mateuszkwiecinski opened this issue Jul 4, 2024 · 6 comments · Fixed by #267
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@mateuszkwiecinski
Copy link
Contributor

Thanks for stopping by to let us know something could be better!


PLEASE READ

If you have a support contract with Google, please create an issue in the support console. This will ensure a timely response.

Discover additional support services for the Google Maps Platform, including developer communities, technical guidance, and expert support at the Google Maps Platform support resources page.

If your bug or feature request is not related to this particular library, please visit the Google Maps Platform issue trackers.

Check for answers on StackOverflow with the google-maps tag.


Please be sure to include as much information as possible:

Environment details

  1. Specify the API at the beginning of the title (for example, "Places: ..."): Kotlin Compiler
  2. OS type and version: Yes
  3. Library version and other environment information: `com.google.maps.android:maps-ktx:5.1.0

Steps to reproduce

  1. Have an build that produces java 11 compatible bytecode i..e
android.kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()

or whatever it is preferred these days
2. Call com.google.maps.android.ktx.awaitMap in the source code
3. Compile the app
image

Expected: The project compiles just fine
Actual: compileDebugKotlin fails with Cannot inline bytecode built with JVM target 17 into bytecode that is being built with JVM target 11. Please specify proper '-jvm-target' option.

My reasoning why this is a bug:

  • Such breaking change was released in minor version bump. I'm not sure which java version targets 5.0.0 but it compiles just fine for a project targeting Java 11
  • Release notes don't mention that change at all
image
  • only some of Java 11 and 17 APIs are available via desugaring on Android, we're still far from most of the devices being able to run (even desugared) Java 17 code. Plus desugaring isn't yet enforced or even enabled by default
  • According to https://developer.android.com/build/jdks#compileSdk Java 17 runtime is available only starting from API 34

More insights:

Related articles:

Code example

# example
fun repro(map : com.google.android.gms.maps.MapView) = map.awaitMap()

Stack trace

# example
`Cannot inline bytecode built with JVM target 17 into bytecode that is being built with JVM target 11. Please specify proper '-jvm-target' option.`

Following these steps will guarantee the quickest resolution possible.

Thanks!

@mateuszkwiecinski mateuszkwiecinski added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jul 4, 2024
@kikoso
Copy link
Collaborator

kikoso commented Jul 4, 2024

Hi @mateuszkwiecinski , thanks for opening this issue.

Actually, this problem goes further in the past. In January we updated some of our libraries to include an upgrade in the Android Gradle Plugin from 7.x to 8.x. This requires us to update the Java version to 17, to support the new plugin version.

This didn't trigger a release and I can't recall the specific reason, but it should have been a major release (i.e., 6.0.0). The current 5.1.0 release includes this new AGP version and some other updates.

I am not sure if it could be worth to release a "lean" 6.0.0 to reflect the breaking change. Probably it could. I am updating also the release notes to reflect this new change.

@mateuszkwiecinski
Copy link
Contributor Author

This requires us to update the Java version to 17, to support the new plugin version.

But that's only for the build, right? The runtime was not affected by AGP bump, was it?

My understanding is you can compile the project with latest java version, but still release artifacts compatible with lower Java versions. Or is it now required for library runtime to use Java 17 features specifically?

@mateuszkwiecinski
Copy link
Contributor Author

I wanted to check what forced you to bump target version and opened: #267
It passed for me locally, including local publishing.

javap -v ~/.m2/repository/com/google/maps/android/maps-utils-ktx/5.1.0/maps-utils-ktx-5.1.0/classes/com/google/maps/android/ktx/utils/LatLngKt.class | grep major

Confirms java 11 compatibility 👀
image

@kikoso
Copy link
Collaborator

kikoso commented Jul 4, 2024

My understanding is you can compile the project with latest java version, but still release artifacts compatible with lower Java versions

This is correct. I honestly do not recall why the Java version was updated back in January, unfortunately logs for past GitHub actions are not available.

The PR you open looks good. Would you mind signing the Google CLA?.

I am thinking of whether this should trigger a minor release. It is technically not a breaking change, but the changes that were merged in January and didn't trigger a release are.

@mateuszkwiecinski
Copy link
Contributor Author

mateuszkwiecinski commented Jul 4, 2024

The PR you open looks good. Would you mind signing the Google CLA?.

Sure, done ✅

I am thinking of whether this should trigger a minor release

I'm not sure what the versioning policy here is. I can propose downgrading the target version further, down to 1.8 as it was it 5.0.0, that way a patch release 5.1.1 would be enough as it will not introduce breaking changes since last major release. That way you could discuss internally which Android runtimes you want to officially support and decide at your own pace

If you keep setup from 5.1.0 and accidentaly start using Java 17 APIs (assuming consumers don't use desugaring), you can start crashing in runtime on devices with API < 34 and nothing will warn you about that. Setup from my PR can crash in runtime on devices with API <29. Downgrading target java version to 1.8 should always work down to API 21 (the one that is mentioned in project's Readme)

@kikoso
Copy link
Collaborator

kikoso commented Jul 4, 2024

I have changed the title to fix: bring back Java 11 compatibility, which should trigger the release 5.1.1.

Leaving some comments on the PR for transparency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants