-
-
Notifications
You must be signed in to change notification settings - Fork 533
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
fix(Android): comply to breaking changes in Android SDK 35 #2258
Merged
+3
−1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Also added comments explaining why the code looks like it looks, because it is not obvious that it won't be refactored at some later point, because it doesn't look "Kotlin-ish". Co-authored-by: Pau Corbella <[email protected]>
This was referenced Aug 23, 2024
This was referenced Aug 27, 2024
This was referenced Sep 24, 2024
ja1ns
pushed a commit
to WiseOwlTech/react-native-screens
that referenced
this pull request
Oct 9, 2024
…mansion#2258) ## Description Initially reported & solution proposed by @corbella83. Newer OpenJDK versions have introduced `List.removeLast` / `List.removeFirst` methods, which haven't existed in JDK before and were provided by Kotlin std lib `kotlin-std`. Android SDK 35 aligns with recent OpenJDK versions & when compiling with SDK 35 the method call is statically resolved to the function from JDK and not to the one from `kotlin-std`. Thus when running on lower version of runtime (<= 34) there is no such method available at runtime (at address resolved in compile time) leading to runtime crash. Section in Android docs describing this: https://developer.android.com/about/versions/15/behavior-changes-15?hl=en#openjdk-api-changes Fixes software-mansion#2257 ## Changes * Replaced call to `drawingOpList.removeLast` with `drawingOpList.removeAt(drawingOpList.lastIndex)`. * Added comment to ensure no one refactors this code bu accident at some later point. ## Test code and steps to reproduce Bump sdk to 35 in Example / FabricExample & run the application. It won't fail in runtime anymore. ## Checklist - [x] Ensured that CI passes CI fails sometimes with some `reanimated` / `gesture-handler` related reasons: <details><summary>Error message</summary> <p> ``` > Task :react-native-gesture-handler:processDebugAndroidTestManifest FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':react-native-gesture-handler:processDebugAndroidTestManifest'. > Could not resolve all files for configuration ':react-native-gesture-handler:debugAndroidTestRuntimeClasspath'. > Failed to transform hermes-android-0.74.1-debug.aar (com.facebook.react:hermes-android:0.74.1) to match attributes {artifactType=android-manifest, com.android.build.api.attributes.BuildTypeAttr=debug, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Execution failed for JetifyTransform: /home/runner/.gradle/caches/modules-2/files-2.1/com.facebook.react/hermes-android/0.74.1/16e198f2042f7758123b39bba3d5e3d6eb33ba8a/hermes-android-0.74.1-debug.aar. > Java heap space ``` </p> </details> which seem unrelated to the PR, but might indicate either some issue with other lib **or** insufficient java heap size. Co-authored-by: Pau Corbella <[email protected]> Co-authored-by: Pau Corbella <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Initially reported & solution proposed by @corbella83.
Newer OpenJDK versions have introduced
List.removeLast
/List.removeFirst
methods, which haven't existed in JDK before and were provided by Kotlin std libkotlin-std
. Android SDK 35 aligns with recent OpenJDK versions & when compiling with SDK 35 the method call is statically resolved to the function from JDK and not to the one fromkotlin-std
. Thus when running on lower version of runtime (<= 34) there is no such method available at runtime (at address resolved in compile time) leading to runtime crash.Section in Android docs describing this: https://developer.android.com/about/versions/15/behavior-changes-15?hl=en#openjdk-api-changes
Fixes #2257
Changes
drawingOpList.removeLast
withdrawingOpList.removeAt(drawingOpList.lastIndex)
.Test code and steps to reproduce
Bump sdk to 35 in Example / FabricExample & run the application. It won't fail in runtime anymore.
Checklist
CI fails sometimes with some
reanimated
/gesture-handler
related reasons:Error message
which seem unrelated to the PR, but might indicate either some issue with other lib or insufficient java heap size.
Co-authored-by: Pau Corbella [email protected]