Skip to content

Conversation

@kkafar
Copy link
Member

@kkafar kkafar commented Jul 22, 2024

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 #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

  • Ensured that CI passes

CI fails sometimes with some reanimated / gesture-handler related reasons:

Error message

> 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

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]

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]>
@kkafar kkafar mentioned this pull request Jul 22, 2024
8 tasks
@kkafar kkafar merged commit de39af6 into main Jul 22, 2024
@kkafar kkafar deleted the @kkafar/fix-android-api-level-35 branch July 22, 2024 08:47
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]>
@Tarsem-tech
Copy link

In which version of react-native-screens to update this line of code

@devsynschismo
Copy link

@Tarsem-tech https://github.com/software-mansion/react-native-screens/releases/tag/3.33.0

@yairopro
Copy link

yairopro commented Aug 14, 2025

I just comment here issue text and keywords to help others to find this post with google. Don't bother.

Kotlin incompatibilities will cause crashes
Your app uses Kotlin's removeFirst() and removeLast() extension functions, which conflict with Java functions in Android 15. This will cause apps to crash on devices on Android 14 or earlier. Your app uses these functions in the following places:
com.swmansion.rnscreens.ScreenStack.obtainDrawingOp
To avoid crashes, replace all Kotlin removeFirst() and removeLast() function calls with removeAt(0) and removeAt(list.lastIndex).

bitmold added a commit to bitmold/quiet that referenced this pull request Aug 21, 2025
bitmold added a commit to bitmold/quiet that referenced this pull request Aug 26, 2025
islathehut added a commit to TryQuiet/quiet that referenced this pull request Sep 4, 2025
* Quiet must target android API 35 (aka "Android 15") in order
to have updates deployed onto the playstore. This rule goes into
effect on August 31, 2025

See: https://support.google.com/googleplay/android-developer/answer/11926878

Also slightly updated READMEs in desktop and mobile packages

* Add guide to using SDKMAN (nvm for JDKs) to mobile README.md

This greatly simplifies installing + using the temurin 17 JDK on any UNIX system, especially if you already have a JDK installed.

* in mobile README remove confusing Android Studio instruction to open Android Studio that only worked on mac from README, replace with ln command that allows you to open Android Studio however you want and works on mac + linux

* in gradle.properties set reactNativeArchitectures to just arm64, currently 32 bit builds were also set here but Quiet only supports 64bit ARM

* Changes needed to build with compileSdk 35

- upgrade toolchain version in  gradle-wrapper.properties
- change NotificationHandler.kt method signature from String? to String to match method signature of new Android API

* Update to NDK 28.1.13356709 and bump gradle dependencies that use native code to
newer releases to support 16KB page sizes for November 1, 2025 play store restriction

Upgrade to android gradle plugin 8.5.1 which is also needed for 16KB pages

Bump external gradle deps to newer releaes supporting 16kb alignment

* light kotlin + java cleanup

* bump react-native-screens from ^3.29.0 to 3.33.0 fixes a crash when compileSdk is 35 and running on a lower android see software-mansion/react-native-screens#2258

* Remove compile warnings form Android manifest, you don't need to set package in here it's ignored, and also useLegacyJni in our gradle overrides this native libs setting

* Ran Android Lint after finding #2977

* Update AndroidManifest.xml

* Minor fix

* Use correct ndk version

* Align ndk between ci and gradle

---------

Co-authored-by: Isla <[email protected]>
islathehut added a commit to TryQuiet/quiet that referenced this pull request Sep 4, 2025
* Quiet must target android API 35 (aka "Android 15") in order
to have updates deployed onto the playstore. This rule goes into
effect on August 31, 2025

See: https://support.google.com/googleplay/android-developer/answer/11926878

Also slightly updated READMEs in desktop and mobile packages

* Add guide to using SDKMAN (nvm for JDKs) to mobile README.md

This greatly simplifies installing + using the temurin 17 JDK on any UNIX system, especially if you already have a JDK installed.

* in mobile README remove confusing Android Studio instruction to open Android Studio that only worked on mac from README, replace with ln command that allows you to open Android Studio however you want and works on mac + linux

* in gradle.properties set reactNativeArchitectures to just arm64, currently 32 bit builds were also set here but Quiet only supports 64bit ARM

* Changes needed to build with compileSdk 35

- upgrade toolchain version in  gradle-wrapper.properties
- change NotificationHandler.kt method signature from String? to String to match method signature of new Android API

* Update to NDK 28.1.13356709 and bump gradle dependencies that use native code to
newer releases to support 16KB page sizes for November 1, 2025 play store restriction

Upgrade to android gradle plugin 8.5.1 which is also needed for 16KB pages

Bump external gradle deps to newer releaes supporting 16kb alignment

* light kotlin + java cleanup

* bump react-native-screens from ^3.29.0 to 3.33.0 fixes a crash when compileSdk is 35 and running on a lower android see software-mansion/react-native-screens#2258

* Remove compile warnings form Android manifest, you don't need to set package in here it's ignored, and also useLegacyJni in our gradle overrides this native libs setting

* Ran Android Lint after finding #2977

* Update AndroidManifest.xml

* Minor fix

* Use correct ndk version

* Align ndk between ci and gradle

---------

Co-authored-by: Isla <[email protected]>
islathehut added a commit to TryQuiet/quiet that referenced this pull request Sep 9, 2025
* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* Fix leaveCommunity flow on Android (#2951)

* fix cleaning ordering and rn bug with ws over tor listener

* fix starter mobile e2e test and add leave community verification

* update changelog

* update changelog for release

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* bug: fix user profile error persisting after close

* Fix Race Conditions in Message Verification and User Profile Indexing (#2954)

* debugging statements - to be reverted

* retry verification when caching messages or getting user updates

* [DEBUG} heads logging - to be removed

* update indexes on init

* just retry current channel when users update; add unit tests

* Revert "debugging statements - to be reverted"

This reverts commit 2f8b2ea.

* rm retryAll from tests

* remove debug logging

* fix verifyMessages test

* add verification retry triggerd by auth update on channel store in backend as well

* e2e test reliability improvement

* update changelog

* patch: msg validation

* Feat/channel debugging tools (#2955)

* add channel debugging panel and gate debug panels on development mode

* update styling

* update changelog

* Revert the submodule change in "add channel debugging panel and gate debug panels on development mode"

This partially reverts commit 8883dd6.

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* fix tor binary path in locally packaged apps (#2962)

* fix tor binary path in locally packaged apps

* restore space in path handling

* fix windows backend test

* use testRegex instead of testMatch

* fix: update CHANGELOG.md to include tor binary path detection fix

* Fix/mac autoupdater (#2966)

* fix tor binary path in locally packaged apps

* restore space in path handling

* fix windows backend test

* use testRegex instead of testMatch

* avoiding preventing default actions when updating

* restore package version

* add fix for automatic updates on mac to changelog

* ensure update modal stays on top

* fix tests

* restore NODE_OPTIONS rm'd during testing

* update release manager

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* Feat/channels sync retries (#2967)

* retry channels syncing when sigchain updates

* Improve channel syncing and refactor setChannel method

* add test proving that reindexing after auth update works

* make test more robust, use custom ipfs access controller on identities, retry joining heads on peer connection

* Ensure entry validation runs only on PUTs

* update changelog

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* rm type from public-channels db

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* Removes cleartext settings in Android app as reported in #2977. (#2978)

Creating rooms + uploading images + posting txt messages works fine without this flag.

* fix: Keyboard avoiding on android, properly displaying send button on android, newline rendering in message component on mobile (#2980)

* Ensure send button shows and fix keyboard hiding input field on android

* Accurately render newlines in messages on mobile

* Android Changes to Meet Two Upcoming Play Store Deadlines (#2974)

* Quiet must target android API 35 (aka "Android 15") in order
to have updates deployed onto the playstore. This rule goes into
effect on August 31, 2025

See: https://support.google.com/googleplay/android-developer/answer/11926878

Also slightly updated READMEs in desktop and mobile packages

* Add guide to using SDKMAN (nvm for JDKs) to mobile README.md

This greatly simplifies installing + using the temurin 17 JDK on any UNIX system, especially if you already have a JDK installed.

* in mobile README remove confusing Android Studio instruction to open Android Studio that only worked on mac from README, replace with ln command that allows you to open Android Studio however you want and works on mac + linux

* in gradle.properties set reactNativeArchitectures to just arm64, currently 32 bit builds were also set here but Quiet only supports 64bit ARM

* Changes needed to build with compileSdk 35

- upgrade toolchain version in  gradle-wrapper.properties
- change NotificationHandler.kt method signature from String? to String to match method signature of new Android API

* Update to NDK 28.1.13356709 and bump gradle dependencies that use native code to
newer releases to support 16KB page sizes for November 1, 2025 play store restriction

Upgrade to android gradle plugin 8.5.1 which is also needed for 16KB pages

Bump external gradle deps to newer releaes supporting 16kb alignment

* light kotlin + java cleanup

* bump react-native-screens from ^3.29.0 to 3.33.0 fixes a crash when compileSdk is 35 and running on a lower android see software-mansion/react-native-screens#2258

* Remove compile warnings form Android manifest, you don't need to set package in here it's ignored, and also useLegacyJni in our gradle overrides this native libs setting

* Ran Android Lint after finding #2977

* Update AndroidManifest.xml

* Minor fix

* Use correct ndk version

* Align ndk between ci and gradle

---------

Co-authored-by: Isla <[email protected]>

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* Add back package name and fix local apk builds (#2983)

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* Bring back cleartext as test

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* Build standard and debug apks

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* Fix debug apk upload

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* Update CHANGELOG

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* Publish

 - @quiet/[email protected]
 - @quiet/[email protected]

* Update packages CHANGELOG.md

* Changelog versions

---------

Co-authored-by: Holmes Wilson <[email protected]>
Co-authored-by: Taea <[email protected]>
Co-authored-by: Taea Vogel <[email protected]>
Co-authored-by: bitmold <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crashing when updating android to api target 35

5 participants