transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
656 stars 277 forks source link

[Android] - App Crash in Android 13 because HMS #1420

Closed fgarciaand closed 6 months ago

fgarciaand commented 7 months ago

Your Environment

// After deviceReady, initial configuration BackgroundGeolocation.ready({ debug: true, logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE, //Parámetros relacionados con la distancia y la localización desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH, distanceFilter: 20, elasticityMultiplier: 1, stopOnTerminate: true, startOnBoot: false, url: ENDPOINT + 'tracking/trackUserLocation', extras: { id: userProfile.getId() }, preventSuspend: true, //Para IOS heartInterval: 60, notification: { title: 'MyApp', text: 'Verificando su seguridad', smallIcon: "mipmap/icon_notification", // <-- defaults to app icon color: '#122a36' }, //Permisos Android 11+ locationAuthorizationRequest: 'Always', backgroundPermissionRationale: { title: "¿Permitir que MyApp acceda a la ubicación de este dispositivo en segundo plano?", message: "Para realizar un seguimiento de su actividad en una situación de Emergencia, habilite el permiso de ubicación a permitir siempre", positiveAction: "Cambiar a permitir siempre", negativeAction: "Cancelar" }, locationAuthorizationAlert: { titleWhenNotEnabled: "Permisos para acceder a la ubicación desactivados", titleWhenOff: "Servicios de ubicación desactivados", instructions: "Para el correcto funcionamiento de MyApp debe habilitar 'Siempre' los servicios de ubicación", cancelButton: "Cancelar", settingsButton: "Configuración" } }).then((state) => { console.log("[ready] BackgroundGeolocation is configured and ready to use", state); }).catch(error => { console.log("[ready] BackgroundGeolocation.ready error: ", error); });

// When an event occurs and App is running in background BackgroundGeolocation.setConfig({ autoSync: true, maxRecordsToPersist: 1, stopAfterElapsedMinutes: 10, stopOnTerminate: false }).then(() => { //Inicio Trackeo en Background BackgroundGeolocation.start(function() { console.log("- Start success"); }); });



## Expected Behavior
Prior to the cordova and plugins update I am performing, the application behaved correctly and did not crash.
## Actual Behavior
After the update the App crashes and the only errors I see in the LoCat are related to this plugin and HMS. This happens only on Android 13, I have tested on later versions of Android and the App does not crash.
Crashes are random but the App almost always crashes.

## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1. Run the App in Android 13
2. When the App starts, BackgroundGeolocation.ready
3. While App is in Background, BackgroundGeolocation.setConfiguration
4. After BackgroundGeolocation.start, App crashes
5. The only errors I see in LogCat are related to this plugin and HMS:
<img width="1426" alt="image_2023_09_25T12_00_36_371Z" src="https://github.com/transistorsoft/cordova-background-geolocation-lt/assets/92478839/0810cd1b-8de6-4fcb-9f3a-6e0a05434e84">

## Context
I have to put the application in tracking mode and keep it in background, for this last one I use cordova-plugin-background-mode. HMS support are not needed.

## Debug logs (AndroidStudio - LogCat)
[myApp.log](https://github.com/transistorsoft/cordova-background-geolocation-lt/files/12728314/myApp.log)
christocracy commented 7 months ago

The HMS log messages are harmless and expected when your app is first launched as the plugin executes methods to discover if the device is running on a device with GMS or HMS installed. They have nothing do do with your app crashing.