Closed rabbiss closed 2 months ago
at com.transistorsoft.rnbackgroundgeolocation.RNBackgroundGeolocationModule.buildGeofence (RNBackgroundGeolocationModule.java:702)
if (config.hasKey("latitude")) { builder.setLatitude(config.getDouble("latitude")); }
Crashes here within react-native's ReadableMap.getValue
.
Can you reproduce this?
I added your code into my SampleApp. The geofence is successfully created and monitored.
The SampleApp uses "react-native": "0.73.0",
await BackgroundGeolocation.addGeofence({
identifier: "mock_identifier",
radius: 200,
latitude: 60.123123123,
longitude: 24.123123123,
notifyOnEntry: true,
notifyOnExit: false,
notifyOnDwell: false,
})
03-12 11:08:09.830 9179 9179 D TSLocationManager: ╔═════════════════════════════════════════════
03-12 11:08:09.830 9179 9179 D TSLocationManager: ║ TSGeofenceManager monitoring 1/1
03-12 11:08:09.830 9179 9179 D TSLocationManager: ╠═════════════════════════════════════════════
03-12 11:08:09.830 9179 9179 D TSLocationManager: ╟─ 🎾 mock_identifier
03-12 11:08:09.830 9179 9179 D TSLocationManager: ╚═════════════════════════════════════════════
I see it in the wilderness of Suomi (small green circle).
Check your code: you MUST be setting latitude: null
somewhere. I can reproduce with the following:
await BackgroundGeolocation.addGeofence({
identifier: "mock_identifier",
radius: 200,
latitude: null, // <---------------------- null
longitude: 24.123123123,
notifyOnEntry: true,
notifyOnExit: false,
notifyOnDwell: false,
})
03-12 11:21:42.253 11566 11609 E AndroidRuntime: com.facebook.react.bridge.NoSuchKeyException: latitude
03-12 11:21:42.253 11566 11609 E AndroidRuntime: at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:113)
03-12 11:21:42.253 11566 11609 E AndroidRuntime: at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:117)
03-12 11:21:42.253 11566 11609 E AndroidRuntime: at com.facebook.react.bridge.ReadableNativeMap.getDouble(ReadableNativeMap.java:154)
03-12 11:21:42.253 11566 11609 E AndroidRuntime: at com.transistorsoft.rnbackgroundgeolocation.RNBackgroundGeolocationModule.buildGeofence(RNBackgroundGeolocationModule.java:702)
Yes, I can now reproduce the error with debugger connected. It is a safe bet that this null value is a bug in the code. Thanks for investigating!
Your Environment
react-native -v
): 0.72.6Expected Behavior
No crashes or exceptions.
Actual Behavior
App crash on com.facebook.react.bridge.NoSuchKeyException
Steps to Reproduce
Reported by Android vitals, so unfortunately no debug logs available. I have not been able to reproduce this issue while debugging either.
Context
I have this stacktrace from Android vitals:
We have multiple reports, right now hundreds of devices affected. Just wondering if you can point me in the right direction, as I don't know where to start looking for the problem.
No such key exception points to latitude. I have checked our geofence methods on the Javascript side, and "latitude" is always defined (it's a fixed value, so no chance of being undefined):
I know this isn't much, but any help would be appreciated!