I was hoping we could ask to review our code and make sure we are doing everything right, because we are seeing issues in production use and we'd like to make sure its not caused by our way of using the library.
react-native -v): 0.51.0app should work
when we start app, sometimes it crashes. In android play console we got two particular errors and we can't understand the reason
I don't find the step to make a crash
App in background mode and try to reopen it or when you start app
BackgroundGeolocation.configure({
// Geolocation Config
desiredAccuracy: 0,
distanceFilter: 20,
maxRecordsToPersist: 0,
maxDaysToPersist: 0,
// Activity Recognition
stopTimeout: 1,
// Application config
debug: false, // <-- enable this hear sounds for background-geolocation life-cycle.
// logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
logLevel: BackgroundGeolocation.LOG_LEVEL_OFF,
stopOnTerminate: true, // <-- Allow the background-service to continue tracking when user closes the app.
startOnBoot: false, // <-- Auto start tracking when device is powered-up.
locationAuthorizationRequest: location === 'undetermined' || location === 'authorized' ? 'Always' : 'WhenInUse',
locationAuthorizationAlert: {
titleWhenNotEnabled: `${t('privacy.title_location_info')}`,
titleWhenOff: `${t('privacy.title_location_info')}`,
instructions: `${t('privacy.description_location_info')}`,
cancelButton: `${t('privacy.not_allow_button')}`,
settingsButton: `${t('privacy.open_setting')}`
}
}, (state) => {
log('- GEOLOCATOR BackgroundGeolocation is configured and ready: ', state.enabled);
if (!state.enabled) {
// 3. Start tracking!
try{
BackgroundGeolocation.start(() => {
log('- GEOLOCATOR Start success');
});
} catch(e) {
// Alert.alert('', 'tracking error');
}
}
}, (err) => {
log('- GEOLOCATOR BackgroundGeolocation is NOT configured and is NOT ready: ', { err });
});
1: java.lang.NullPointerException:
at com.transistorsoft.locationmanager.event.GeofencesChangeEvent.getStatus (Unknown Source:27)
at com.transistorsoft.locationmanager.event.LocationProviderChangeEvent.
at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation$c.a (Unknown Source:153)
at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation$c.run (Unknown Source:11)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
at java.lang.Thread.run (Thread.java:764)
2 java.lang.NullPointerException:
at com.transistorsoft.locationmanager.event.HeartbeatEvent.isEnabled (Unknown Source)
at com.transistorsoft.locationmanager.event.LocationProviderChangeEvent.
at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation$c.a (Unknown Source)
at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation$c.run (Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
at java.lang.Thread.run (Thread.java:761)
There's no such plugin version 10.0.1.
The latest is 2.12.0-beta.3
sorry, the correct plugin version is 2.10.1
Hi I have a similar issue, my app is crashing and i don't understand why. On one hand i have my project that is normally working without BackgroundGeolocation and crashing with it. The configuration is :
"react": "16.2.0",
"react-favicon": "0.0.13",
"react-native": "0.51.0",
"react-native-background-geolocation": "^2.12.0-beta.3",
"react-native-camera-roll-picker": "^1.2.3",
"react-native-elements": "^0.19.0",
"react-native-maps": "^0.20.1",
"react-native-maps-directions": "^1.6.0",
"react-native-push-notification": "^3.0.2",
"react-native-vector-icons": "^4.6.0",
"react-navigation": "^1.2.0"
on the other hand I have a small project that I create a small project to test your module and it's working well. The configuration is :
"react": "16.3.1",
"react-native": "0.55.2",
"react-native-background-geolocation": "^2.12.0-beta.3"
So I was wondering maybe there is a minimal version of react-native that is needed or maybe there is a conflict with an other module. I'm trying to resolve this issue since a few days now. Thanks
When you have an app crashing, the first thing you do is get the stacktrace from adb logcat. Where鈥檚 your stacktrace?
Yes sorry, here it is :
--------- beginning of crash
--------- beginning of system
--------- beginning of main
04-10 13:26:53.454 5681 5681 D ReactNative: ReactInstanceManager.ctor()
04-10 13:26:53.519 5681 5681 D ReactNative: ReactInstanceManager.createReactContextInBackground()
04-10 13:26:53.519 5681 5681 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
04-10 13:27:24.240 5681 5681 D ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()
04-10 13:27:24.241 5681 5681 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
04-10 13:27:24.241 5681 5681 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
04-10 13:27:24.354 5681 5958 D ReactNative: ReactInstanceManager.createReactContext()
04-10 13:27:26.188 6011 6011 D ReactNative: ReactInstanceManager.ctor()
04-10 13:27:26.254 6011 6011 D ReactNative: ReactInstanceManager.createReactContextInBackground()
04-10 13:27:26.254 6011 6011 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
04-10 13:27:26.260 6011 6011 D ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()
04-10 13:27:26.261 6011 6011 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
04-10 13:27:26.261 6011 6011 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
04-10 13:27:26.292 6011 6036 D ReactNative: ReactInstanceManager.createReactContext()
04-10 13:27:53.151 6112 6112 D ReactNative: ReactInstanceManager.ctor()
04-10 13:27:53.208 6112 6112 D ReactNative: ReactInstanceManager.createReactContextInBackground()
04-10 13:27:53.208 6112 6112 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
04-10 13:27:53.210 6112 6112 D ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()
04-10 13:27:53.211 6112 6112 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
04-10 13:27:53.211 6112 6112 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
04-10 13:27:53.233 6112 6136 D ReactNative: ReactInstanceManager.createReactContext()
That's not a stacktrace. Those are just log messages.
When an app crashes, you'll see a stack-trace like this (following is just a random stack-trace unrelated to the plugin)
04-10 08:53:39.025 30860 30860 E WorkController: Loading failed for worker [context]
04-10 08:53:39.025 30860 30860 E WorkController: java.lang.IllegalStateException: WorkerManager is disposed
04-10 08:53:39.025 30860 30860 E WorkController: at com.google.android.apps.gsa.search.core.service.f.b.c.hr(SourceFile:7)
04-10 08:53:39.025 30860 30860 E WorkController: at com.google.android.apps.gsa.search.core.service.workcontroller.a.d.run(Unknown Source:20)
04-10 08:53:39.025 30860 30860 E WorkController: at com.google.android.apps.gsa.shared.util.concurrent.b.br.bes(SourceFile:2)
04-10 08:53:39.025 30860 30860 E WorkController: at com.google.android.apps.gsa.shared.util.concurrent.b.bp.run(SourceFile:2)
04-10 08:53:39.025 30860 30860 E WorkController: at android.os.Handler.handleCallback(Handler.java:790)
04-10 08:53:39.025 30860 30860 E WorkController: at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 08:53:39.025 30860 30860 E WorkController: at android.os.Looper.loop(Looper.java:164)
04-10 08:53:39.025 30860 30860 E WorkController: at android.app.ActivityThread.main(ActivityThread.java:6494)
04-10 08:53:39.025 30860 30860 E WorkController: at java.lang.reflect.Method.invoke(Native Method)
04-10 08:53:39.025 30860 30860 E WorkController: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
04-10 08:53:39.025 30860 30860 E WorkController: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
@tony992 My latest messages are directed @ValOscar. I saw your stacktraces in the initial issue comment.
@tony992 Have you tried the latest 2.12.0?
Update on this please.
Hi @christocracy, I am having the same problem and am not being given a stack trace. Nothing in my packager, react-native run-android nor in react-native log-android
@visagegod You can view the stacktrace by connecting your device to USB and running:
$ adb logcat
My app crash too. still looking for solution
@chuchden there are thousands of ways an app can crash. This issue has nothing to do with you.
Most helpful comment
Yes sorry, here it is :
--------- beginning of crash
--------- beginning of system
--------- beginning of main
04-10 13:26:53.454 5681 5681 D ReactNative: ReactInstanceManager.ctor()
04-10 13:26:53.519 5681 5681 D ReactNative: ReactInstanceManager.createReactContextInBackground()
04-10 13:26:53.519 5681 5681 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
04-10 13:27:24.240 5681 5681 D ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()
04-10 13:27:24.241 5681 5681 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
04-10 13:27:24.241 5681 5681 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
04-10 13:27:24.354 5681 5958 D ReactNative: ReactInstanceManager.createReactContext()
04-10 13:27:26.188 6011 6011 D ReactNative: ReactInstanceManager.ctor()
04-10 13:27:26.254 6011 6011 D ReactNative: ReactInstanceManager.createReactContextInBackground()
04-10 13:27:26.254 6011 6011 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
04-10 13:27:26.260 6011 6011 D ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()
04-10 13:27:26.261 6011 6011 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
04-10 13:27:26.261 6011 6011 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
04-10 13:27:26.292 6011 6036 D ReactNative: ReactInstanceManager.createReactContext()
04-10 13:27:53.151 6112 6112 D ReactNative: ReactInstanceManager.ctor()
04-10 13:27:53.208 6112 6112 D ReactNative: ReactInstanceManager.createReactContextInBackground()
04-10 13:27:53.208 6112 6112 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
04-10 13:27:53.210 6112 6112 D ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()
04-10 13:27:53.211 6112 6112 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
04-10 13:27:53.211 6112 6112 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
04-10 13:27:53.233 6112 6136 D ReactNative: ReactInstanceManager.createReactContext()