transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.65k stars 426 forks source link

App crash with error: org.slf4j.helpers.SubstituteLogger cannot be cast to ch.qos.logback.classic.Logger #1699

Closed ankur-sanghvi closed 1 year ago

ankur-sanghvi commented 1 year ago

Your Environment

const config = { desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH, url: BEECON_API_URL + '/api/xxxxx', headers: { authorization: 'Bearer ' + configsData?.beeconAPIToken, }, params: { imei: configsData?.beeconVehicleImei, org: { id: configsData?.beeconOrgId }, id: configsData?.beeconVehicleId, brand: 'cellularDevice', model: DeviceInfo.getBrand(), variant: DeviceInfo.getDeviceId(), }, notification: { priority: BackgroundGeolocation.NOTIFICATION_PRIORITY_MAX, }, enableTimestampMeta: true, isMoving: true, autoSync: true, heartbeatInterval: 60, // To enable Headless, enableHeadless -> true and stopOnTerminate -> false enableHeadless: backgroundGeoConfig?.enableHeadless, stopOnTerminate: backgroundGeoConfig?.stopOnTerminate, startOnBoot: backgroundGeoConfig?.startOnBoot, stopTimeout: backgroundGeoConfig?.stopTimeout, locationAuthorizationRequest: 'Always', backgroundPermissionRationale: { title: '{applicationName} App collects location data to enable Daily KM Tracking, even when the app is closed or not in use', message: ' ', positiveAction: 'Change to "{backgroundPermissionOptionLabel}"', }, autoSyncThreshold: backgroundGeoConfig?.autoSyncThreshold, distanceFilter: backgroundGeoConfig?.distanceFilter, maxBatchSize: backgroundGeoConfig?.maxBatchSize, batchSync: backgroundGeoConfig?.batchSync, debug: backgroundGeoConfig?.debug, locationUpdateInterval: backgroundGeoConfig?.locationUpdateInterval, logLevel: backgroundGeoConfig?.logLevel, logMaxDays: backgroundGeoConfig?.logMaxDays, // motionTriggerDelay: 10000 }


## Expected Behavior
the app should not crash when react-native-vision-camera opens up and should be able to scan the barcode

## Actual Behavior
the app is crashing after a few seconds of opening a camera

## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1. navigate to the camera screen
2. after the camera is initiated it will crash

## Context
Here I am trying to integrate the react-native-vision-camera plugin known as vision-camera-code-scanner, but after installing this package and integrating the plugin with the vision-camera package it started crashing after the camera started with below crash error log

## Debug logs
<!-- include iOS / Android logs
- ios XCode logs,
- use #getLog #emailLog methods (@see docs)
- Android: $ adb logcat -s TSLocationManager
-->
<details><summary>Logs</summary>

``` <!-- Syntax highlighting:  DO NOT REMOVE -->
FATAL EXCEPTION: pool-22-thread-2

java.lang.ClassCastException: org.slf4j.helpers.SubstituteLogger cannot be cast to ch.qos.logback.classic.Logger

FATAL EXCEPTION: pool-22-thread-2
Process: com.loadshare.deliveryapp, PID: 31347
java.lang.ClassCastException: org.slf4j.helpers.SubstituteLogger cannot be cast to ch.qos.logback.classic.Logger
    at com.transistorsoft.locationmanager.logger.TSLog.getRootLogger(Unknown Source:10)
    at com.transistorsoft.locationmanager.logger.TSLog.access$000(Unknown Source:0)
    at com.transistorsoft.locationmanager.logger.TSLog$a.run(Unknown Source:0)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
    at java.lang.Thread.run(Thread.java:1012)

christocracy commented 1 year ago
$ cd android 
$ ./gradlew app:dependencies
ankur-sanghvi commented 1 year ago

Here attaching log file file-log.txt

christocracy commented 1 year ago

You have multiple modules requiring the same Android logger library that this plugin uses org.slf4j.

Background Geolocation imports the latest version 2.0.7 while org.java-websocket-Java-WebSocket imports the older 1.7.25.

debugReverseMetadataValues - Metadata Values dependencies for the base Split
No dependencies

debugRuntimeClasspath - Resolved configuration for runtime for variant: debug
+--- com.facebook.flipper:flipper:0.125.0
|    .
.    .
.    .
.    .
|    \--- org.java-websocket:Java-WebSocket:1.5.2
|         \--- org.slf4j:slf4j-api:1.7.25 -> 2.0.7  <----- older 1.7.25
.
.
.
+--- project :react-native-background-geolocation
.    .
.    .
.    .
|    +--- com.github.tony19:logback-android:3.0.0
|    +--- org.slf4j:slf4j-api:2.0.7  // <--------- 2.0.7

Solution

buildscript {
    ext {
        .
        .
        .
        slf4jVersion = "1.7.36"
        logbackVersion = "2.0.1"
    }
}
ankur-sanghvi commented 1 year ago

Ok @christocracy thanks for the help