Summary
BaseLocationManager.putIntoMap crashes on Android 12+ with a ClassCastException:
java.lang.Long cannot be cast to java.lang.Integer.
Environment
- Library version: 3.3.0 (also reproduces on 3.4.0)
- React Native version: 0.73.9
- Android version/device: Android 12, Xiaomi 11 Lite 5G NE (real device)
Steps to reproduce
- Call
Geolocation.getCurrentPosition (or start observing location).
- When Google Play services populates
Location.getExtras() with Long values
(e.g. GNSS satellite count), the library tries to cast to Integer.
Stack trace
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
at com.reactnativecommunity.geolocation.BaseLocationManager.putIntoMap(BaseLocationManager.java:53)
at com.reactnativecommunity.geolocation.BaseLocationManager.locationToMap(BaseLocationManager.java:38)
...
Expected behaviour
Extras should be forwarded without crashing (Long should be handled safely).
Proposed fix
Treat any Number generically or handle Long before Integer.
I can send a PR with the change if that helps.
Summary
BaseLocationManager.putIntoMapcrashes on Android 12+ with a ClassCastException:java.lang.Long cannot be cast to java.lang.Integer.Environment
Steps to reproduce
Geolocation.getCurrentPosition(or start observing location).Location.getExtras()with Long values(e.g. GNSS satellite count), the library tries to cast to Integer.
Stack trace
Expected behaviour
Extras should be forwarded without crashing (Long should be handled safely).
Proposed fix
Treat any Number generically or handle Long before Integer.
I can send a PR with the change if that helps.