react-native-multiple-image-picker icon indicating copy to clipboard operation
react-native-multiple-image-picker copied to clipboard

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

Open Burundug opened this issue 9 months ago • 0 comments

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

  • Replaced _javaPart->getClass() with _javaPart->javaClassStatic()
  • Based on a similar fix from react-native-nitro: https://github.com/mrousavy/nitro/pull/582

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.

Burundug avatar Mar 07 '25 11:03 Burundug