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

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

Closed
ankur-sanghvi opened this issue Jun 5, 2023 · 4 comments

Comments

@ankur-sanghvi
Copy link

ankur-sanghvi commented Jun 5, 2023

Your Environment

  • Plugin version: 4.12.0
  • Platform: Android
  • OS version: Android 12
  • Device manufacturer/model: Oneplus Nord CE
  • React Native version (react-native -v): 0.68.5
  • Plugin config
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

  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

Logs
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
Copy link
Member

$ cd android 
$ ./gradlew app:dependencies

@ankur-sanghvi
Copy link
Author

Here attaching log file
file-log.txt

@christocracy
Copy link
Member

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

  • In your android/build.gradle, add the following ext variables:
buildscript {
    ext {
        .
        .
        .
        slf4jVersion = "1.7.36"
        logbackVersion = "2.0.1"
    }
}

@ankur-sanghvi
Copy link
Author

Ok @christocracy thanks for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants