Cordova-plugin-background-geolocation: App crash on this.backgroundGeolocation.start();

Created on 8 Nov 2018  Â·  6Comments  Â·  Source: mauron85/cordova-plugin-background-geolocation

Our project app crashes at the execution of 'this.backgroundGeolocation.start();'

Your Environment

Plugin version: 2.3.6
Platform: Android
OS version: Android 8.1.0
Device manufacturer and model: Google Pixel 2 & Xiaomi Redmi 5 Pro

Context

The App always crashes on 'this.backgroundGeolocation.start();' with no logs in the console.
I created an empty ionic demo Project just to test the plugin on the 08.08.18 and there the plugin worked fine but at the moment at also crashes the demo app as well.

Expected Behavior

The Demo app should log the tracked coordinates on the screen.

Actual Behavior

If the app reaches the line of code where: 'this.backgroundGeolocation.start();' is called it just crashes.

Possible Fix

¯_(ツ)_/¯

Steps to Reproduce


  1. clone the project: https://github.com/wrunkel/ionic3-backgroundGeolocation-demo
  2. build the project.
  3. deploy the project.
  4. test on device.

Context

GPS tracking of the traveled route to display it on a map later on.

Debug logs

11-08 16:05:19.742 18927-18927/com.caranea.fahrtenbuch E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.caranea.fahrtenbuch, PID: 18927
android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification(channel=null pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x62 color=0x00000000 vis=PRIVATE)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1768)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Most helpful comment

So downgrading "cordova android platform" or "cordova-android" from 7.1.1 to 7.0.0 worked fine for me with "cordova-plugin-mauron85-background-geolocation": "2.3.6",. The App dosen't crash anymore and logs the GPS coordinates.

Thanks a lot!

All 6 comments

Not sure, but I think you will not be able to use latest cordova android platform, since they're targeting oreo APIs. Oreo brought new backward incompatible requirements for notifications. Try use older cordova or upgrade to 3.x branch of the plugin.

Here is the current config of the plugin:

const config: BackgroundGeolocationConfig = {
desiredAccuracy: 0,
stationaryRadius: 1,
distanceFilter: 1,
activitiesInterval: 1000,
fastestInterval: 900,
saveBatteryOnBackground: false,
interval: 5000,
debug: true, // enable this hear sounds for background-geolocation life-cycle.
stopOnTerminate: false, // enable this to clear background location settings when the app terminates
};

Sorry. my previous post (now deleted) was posted by mistake (it was targeting different issue). This is not configuration issue.

You can check installed version of "cordova-android" in node_modules/cordova-android/package.json. Should not be the newest, but rather 7.1.0 or something close.

EDIT: edited

Also not sure if it's possible to target pre oreo API level on Pixel2 phone. If not, then you'll have to use 3.x version.

all right, i will try it out and let you know, thanks for now for the quick response :-)

So downgrading "cordova android platform" or "cordova-android" from 7.1.1 to 7.0.0 worked fine for me with "cordova-plugin-mauron85-background-geolocation": "2.3.6",. The App dosen't crash anymore and logs the GPS coordinates.

Thanks a lot!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maurojones picture maurojones  Â·  3Comments

frankzhangxd picture frankzhangxd  Â·  6Comments

kleeb picture kleeb  Â·  8Comments

steveharbick picture steveharbick  Â·  5Comments

shyamal890 picture shyamal890  Â·  10Comments