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

fix(android): replace getClass() with javaClassStatic() #225

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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

1 participant