Skip to content

Conversation

Burundug
Copy link

@Burundug Burundug commented Mar 7, 2025

Summary

This PR fixes a crash on Android 8+ caused by using _javaPart->getClass()
to retrieve the Java class.

The correct approach is to use _javaPart->javaClassStatic(),
which avoids compatibility issues.

Changes

Why?

On certain devices, getClass() is not allowed and leads to crashes
when trying to access JNI methods. This update ensures better compatibility.

Test Plan

  • Tested on Android 8, 10, 13.
  • Confirmed that openPicker() and other related functions work as expected.

…lity

Android 8+ restricts the usage of getClass() in certain cases, causing crashes.
This commit replaces `_javaPart->getClass()` with `_javaPart->javaClassStatic()`,
which is a more stable approach.

This change is based on a similar fix in react-native-nitro:
mrousavy/nitro#582
Copy link
Member

@baronha baronha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try new nitro modules version?

@baronha baronha closed this Aug 10, 2025
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.

2 participants