-
Notifications
You must be signed in to change notification settings - Fork 24
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
Context.startForegroundService() did not then call Service.startForeground() on Android 8.1 #121
Comments
Do you have your license key configured? |
I do, other than this error it works with the release apk. |
Show me your code you’re using to control the plugin. |
Below is the code I use to start the plugin. if (platform.isAndroid) {
permissions.requestPermission([
android.Manifest.permission.ACCESS_FINE_LOCATION,
android.Manifest.permission.ACCESS_COARSE_LOCATION],
"We really need your location since it's a location based game ;)")
.then(() => {
// // 1. Listen to events
BackgroundGeolocation.on('location', this.onLocation.bind(this));
BackgroundGeolocation.on('motionchange', this.onMotionChange.bind(this));
BackgroundGeolocation.on('http', this.onHttp.bind(this));
BackgroundGeolocation.on('heartbeat', this.onHeartbeat.bind(this));
BackgroundGeolocation.on('error', this.onError.bind(this));
// 2. Configure it.
BackgroundGeolocation.configure({
debug: false,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
stationaryRadius: 25,
distanceFilter: 50,
activityRecognitionInterval: 10000,
notificationText: 'Loco service activated',
notificationIcon: 'drawable/ic_notification',
url: `${config.API_HOST}/v1/game/${this.rootStore.game._id}/player/${this.rootStore.game.gamePlayerId}/location`
}, (state) => {
// 3. Plugin is now ready to use.
if (!state.enabled) {
console.log('LOCATION STARTING');
BackgroundGeolocation.start();
}
});
});
} |
You don’t need to worry about location permissions. The plugin handles that by itself. This error can occur if you call #start and immediately #stop. |
Thanks for the fast response. I did have that case in a while ago so that could be the reason for this error, have refactored a bit since to remove this. I still can't get the beta3 to work in release builds on 8.1 as mentioned in this issue, #117 . |
Show |
I don’t need hours of logs. I just want a snapshot of your app booting from scratch. Shouldn’t be more than 15 seconds of logs. |
:) Just ran |
Logcat is a live stream of the logs.
I deleted your previous message. |
It's what I just did in the last comment which you removed. I cleared all the history, started the logcat, started the app, pressed [ctrl][c] after launching the app and pasted here. App does not crash. The background service seems to never start. No notification is present for the service and the location is not working in the app. |
If it doesn’t crash, show filtered plugin-only logs of your app booting.
|
It's empty with
|
Add config: { |
Still nothing in the log ( Log output:
Setup:
Same configuration just changing |
Read the docs very carefully for new After modifying config, you must provide |
Made a new build with below config which includes
|
|
|
There is no sign of the plugin in your logs. You are not executing |
So as I've mentioned in this comment: #117 (comment)
console.log('Before first reference');
// WITH VERSION 1.9.0x this line logs as expected
BackgroundGeolocation.on('location', this.onLocation.bind(this));
BackgroundGeolocation.on('motionchange', this.onMotionChange.bind(this));
BackgroundGeolocation.on('http', this.onHttp.bind(this));
BackgroundGeolocation.on('heartbeat', this.onHeartbeat.bind(this));
BackgroundGeolocation.on('error', this.onError.bind(this));
console.log('After first reference');
// WITH VERSION 1.9.0x and with release build this line is never reached and no error is thrown, with version 1.8.0 release build I don't have this problem
// 2. Configure it.
BackgroundGeolocation.ready({
logLevel: 5,
reset: true,
debug: true,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
stationaryRadius: 25,
distanceFilter: 50,
activityRecognitionInterval: 10000,
notificationText: 'Loco service activated',
notificationIcon: 'drawable/ic_notification',
url: `${config.API_HOST}/v1/game/${this.rootStore.game._id}/player/${this.rootStore.game.gamePlayerId}/location`
}, (state) => {
// 3. Plugin is now ready to use.
if (!state.enabled) {
console.log('LOCATION STARTING');
BackgroundGeolocation.start();
}
}); |
You must not have the plugin installed correctly or you have a problem with your environment. If you
You'll likely find that it's
|
It works with
|
I just produced a release apk of the demo app. It works fine. Do you explicitly set Attached is my release apk. NOTE I had to change the
|
Thanks for the build. This works. My
Also
|
Show me the first 5 chars of your license key. |
1af76 |
We're also seeing this happen (infrequently).
|
We are also seeing this error, any updates? android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground() |
Your Environment
tns info
): 4.1.2Expected Behavior
App shouldn't crash.
Actual Behavior
App crashes throwing
Context.startForegroundService() did not then call Service.startForeground()
error.This library is the only background service I'm using in the app so I'm assuming there's an issue here.
Steps to Reproduce
It's random, it happens every once in a while when putting the app to background and back to foreground.
Context
Nothing particular.
Debug logs
The text was updated successfully, but these errors were encountered: