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

Attempt to invoke virtual method 'void com.marianhello.bgloc.LocationService.start()' on a null object reference #232

Closed
Yusiro85 opened this issue Jul 10, 2018 · 12 comments
Labels
stale auto labeled abandoned issues after a period of inactivity

Comments

@Yusiro85
Copy link

Your Environment

Plugin version: 0.5.0-alpha.34
Platform: Android
OS version: 7.0
Device manufacturer and model: Huawei VIE-L29
React Native version: 0.51.0
Plugin configuration options:
BackgroundGeolocation.configure({
distanceFilter: 50,
debug: false,
startOnBoot: false,
stationaryRadius: 50,
stopOnTerminate: true,
desiredAccuracy: 10,
interval: 15000
});
Link to your project:

Context

Expected Behavior

Launch the app and run without issue, start tracking location

Actual Behavior

Crash after launch and login the app

Possible Fix

Steps to Reproduce

Context

Debug logs

java.lang.NullPointerException Attempt to invoke virtual method 'void com.marianhello.bgloc.LocationService.start()' on a null object reference
BackgroundGeolocationFacade.java:451 com.marianhello.bgloc.BackgroundGeolocationFacade.startBackgroundService
BackgroundGeolocationFacade.java:49 com.marianhello.bgloc.BackgroundGeolocationFacade.access$700
BackgroundGeolocationFacade.java:222 com.marianhello.bgloc.BackgroundGeolocationFacade$3.onPermissionGranted
PermissionHandler.java:41 com.intentfilter.androidpermissions.PermissionHandler.checkPermissions
PermissionManager.java:50 com.intentfilter.androidpermissions.PermissionManager.checkPermissions
BackgroundGeolocationFacade.java:215 com.marianhello.bgloc.BackgroundGeolocationFacade.start
BackgroundGeolocationModule.java:145 com.marianhello.bgloc.react.BackgroundGeolocationModule.start
Method.java:-2 java.lang.reflect.Method.invoke
JavaMethodWrapper.java:374 com.facebook.react.bridge.JavaMethodWrapper.invoke
JavaModuleWrapper.java:162 com.facebook.react.bridge.JavaModuleWrapper.invoke
NativeRunnable.java:-2 com.facebook.react.bridge.queue.NativeRunnable.run
Handler.java:761 android.os.Handler.handleCallback
Handler.java:98 android.os.Handler.dispatchMessage
MessageQueueThreadHandler.java:31 com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
Looper.java:156 android.os.Looper.loop
MessageQueueThreadImpl.java:194 com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run
Thread.java:776 java.lang.Thread.run

@Yusiro85
Copy link
Author

Is this due to race condition? Hit this while launching the app.

@Yusiro85
Copy link
Author

Yusiro85 commented Jul 13, 2018

randomly getting this bug as well. This is on Plugin version: 0.5.0-alpha.21 though

java.lang.NullPointerException Attempt to invoke virtual method 'java.lang.String android.location.Location.getProvider()' on a null object reference
BackgroundLocation.java:46 com.marianhello.bgloc.data.BackgroundLocation.
AbstractLocationProvider.java:113 com.marianhello.bgloc.provider.AbstractLocationProvider.handleStationary
DistanceFilterLocationProvider.java:301 com.tenforwardconsulting.bgloc.DistanceFilterLocationProvider.onLocationChanged
LocationManager.java:374 android.location.LocationManager$ListenerTransport._handleMessage
LocationManager.java:-1 android.location.LocationManager$ListenerTransport.-wrap0
LocationManager.java:242 android.location.LocationManager$ListenerTransport$1.handleMessage
Handler.java:110 android.os.Handler.dispatchMessage
Looper.java:232 android.os.Looper.loop
ActivityThread.java:6802 android.app.ActivityThread.main
Method.java:-2 java.lang.reflect.Method.invoke
ZygoteInit.java:1103 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
ZygoteInit.java:964 com.android.internal.os.ZygoteInit.main

@mauron85

@mauron85
Copy link
Owner

@Yusiro85 are you launching your app from notification?

@Yusiro85
Copy link
Author

nope. I didn't.

@mauron85
Copy link
Owner

mauron85 commented Jul 13, 2018

Have you modified plugin somehow? Or using vanilla? Because lines from your stack trace doesn't match. Eg.

BackgroundGeolocationModule.java:145 

Line 145 of plugin in version 0.5.0-alpha.34 is method declaration so it could not crash there.

public void switchMode(Integer mode, Callback success, Callback error) {

@Yusiro85
Copy link
Author

Yes, I did apply a wakelock.acquire in Constructor and release it in onHostDestroy.
Is this the cause?

@mauron85
Copy link
Owner

Probably not, but it made error stacktrace useless.

@Yusiro85
Copy link
Author

java.lang.NullPointerException Attempt to invoke virtual method 'void com.marianhello.bgloc.LocationService.start()' on a null object reference
BackgroundGeolocationFacade.java:451 com.marianhello.bgloc.BackgroundGeolocationFacade.startBackgroundService
BackgroundGeolocationFacade.java:49 com.marianhello.bgloc.BackgroundGeolocationFacade.access$700
BackgroundGeolocationFacade.java:222 com.marianhello.bgloc.BackgroundGeolocationFacade$3.onPermissionGranted
PermissionHandler.java:41 com.intentfilter.androidpermissions.PermissionHandler.checkPermissions
PermissionManager.java:50 com.intentfilter.androidpermissions.PermissionManager.checkPermissions
BackgroundGeolocationFacade.java:215 com.marianhello.bgloc.BackgroundGeolocationFacade.start
BackgroundGeolocationModule.java:145 com.marianhello.bgloc.react.BackgroundGeolocationModule.start
Method.java:-2 java.lang.reflect.Method.invoke
JavaMethodWrapper.java:374 com.facebook.react.bridge.JavaMethodWrapper.invoke
JavaModuleWrapper.java:162 com.facebook.react.bridge.JavaModuleWrapper.invoke
NativeRunnable.java:-2 com.facebook.react.bridge.queue.NativeRunnable.run
Handler.java:761 android.os.Handler.handleCallback
Handler.java:98 android.os.Handler.dispatchMessage
MessageQueueThreadHandler.java:31 com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
Looper.java:156 android.os.Looper.loop
MessageQueueThreadImpl.java:194 com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run
Thread.java:776 java.lang.Thread.run

what about this error? this is based on Plugin version: 0.5.0-alpha.21.
I didn't modify anything but still hit this error.

@mauron85
Copy link
Owner

mauron85 commented Jul 13, 2018

Not sure what is your reason to stay on old alpha (since you're not opening app from notification and that for not affected by #201)

But if you need to stay on old alpha pick up 3.0.0-alpha.22, because of this (from CHANGELOG.md) fix:

image

@Yusiro85
Copy link
Author

Ok thanks for pointing me in the right direction.
I'll update to alpha 22 and try again.

@stale
Copy link

stale bot commented Jan 9, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale auto labeled abandoned issues after a period of inactivity label Jan 9, 2019
@stale
Copy link

stale bot commented Jan 16, 2019

This issue has been automatically closed, because it has not had recent activity. If you believe this issue shouldn't be closed, please reopen or write down a comment requesting issue reopening with explanation why you think it's important. Thank you for your contributions.

@stale stale bot closed this as completed Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale auto labeled abandoned issues after a period of inactivity
Projects
None yet
Development

No branches or pull requests

2 participants