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

Help with java.lang.ClassCastException with Logs #1401

Closed sebastianlezica closed 11 months ago

sebastianlezica commented 12 months ago

Hello, I have a problem, my app, in Android, compile without java.lang.ClassCastException: org.slf4j.helpers.NOPLogger cannot be cast to ch.qos.logback.classic.Logger. I buy the license a couple of years ago (and really love this plugin! save my life!). Really appreciate any help, I found some info about this problem but not see any other with the same error, I guess is only mine. Try ten or more times rebuilt from scratch, delete the node_modules (cache and folder), platforms and plugins folders, but every time I get the same error. Found some references, https://stackoverflow.com/questions/31433246/classcastexception-org-slf4j-impl-log4jloggeradapter-cannot-be-cast-to-ch-qos-l and https://stackoverflow.com/questions/54652836/slf4j-found-slf4j-api-dependency-but-no-providers-were-found but can't get any enlightment to my mind ;).

Really thanks!,

Sebastian

Your Environment

Expected Behavior

For a couple of years this rutine work without problems. In the past, this snippet start the geolocation service without problems.

Actual Behavior

When I update all the environment for target the app to Android 12 (following the Google's new rules), and after a couple of changes and plugin updates, the app close and in logcat I see the fatal error "java.lang.ClassCastException: org.slf4j.helpers.NOPLogger cannot be cast to ch.qos.logback.classic.Logger".

Steps to Reproduce

This error happen with the npm version and the master from git.

Context

Start the geolocation service ;)

Debug logs

Logs ``` logcat: 05-08 22:07:37.280 29971 30268 E AndroidRuntime: FATAL EXCEPTION: pool-4-thread-1 05-08 22:07:37.280 29971 30268 E AndroidRuntime: Process: com.dosalinfinito.am.basic, PID: 29971 05-08 22:07:37.280 29971 30268 E AndroidRuntime: java.lang.ClassCastException: org.slf4j.helpers.NOPLogger cannot be cast to ch.qos.logback.classic.Logger 05-08 22:07:37.280 29971 30268 E AndroidRuntime: at com.transistorsoft.locationmanager.logger.TSLog.getRootLogger(Unknown Source:10) 05-08 22:07:37.280 29971 30268 E AndroidRuntime: at com.transistorsoft.locationmanager.logger.TSLog.access$000(Unknown Source:0) 05-08 22:07:37.280 29971 30268 E AndroidRuntime: at com.transistorsoft.locationmanager.logger.TSLog$a.run(Unknown Source:0) 05-08 22:07:37.280 29971 30268 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) 05-08 22:07:37.280 29971 30268 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) 05-08 22:07:37.280 29971 30268 E AndroidRuntime: at java.lang.Thread.run(Thread.java:1012) ---------------------------------------------- cli return at compilation: C:\opt\phonegap\AsistManager>call cordova build android --debug cordova-android-play-services-gradle-release: overriding com.google.android.gms:play-services-auth:11.8.0 in build.gradle with com.google.android.gms:play-services-auth:20.+ cordova-android-play-services-gradle-release: overriding com.google.android.gms:play-services-identity:11.8.0 in build.gradle with com.google.android.gms:play-services-identity:18.+ cordova-android-play-services-gradle-release: overriding com.google.android.gms:play-services-location:16.+ in build.gradle with com.google.android.gms:play-services-location:20.+ cordova-android-play-services-gradle-release: overriding com.google.android.gms:play-services-auth:11.8.0 in build.gradle with com.google.android.gms:play-services-auth:20.+ cordova-android-play-services-gradle-release: overriding com.google.android.gms:play-services-identity:11.8.0 in build.gradle with com.google.android.gms:play-services-identity:18.+ cordova-android-play-services-gradle-release: overriding com.google.android.gms:play-services-location:16.+ in build.gradle with com.google.android.gms:play-services-location:20.+ cordova-plugin-androidx-adapter: Processed 134 source files in 2913ms Checking Java JDK and Android SDK versions ANDROID_HOME=c:\Users\slezi\AppData\Local\Android\Sdk (recommended setting) ANDROID_SDK_ROOT=c:\users\slezi\appdata\local\android\sdk (DEPRECATED) Using Android SDK: c:\users\slezi\appdata\local\android\sdk Reading build config file: C:\opt\phonegap\AsistManager\build.json Reading the keystore from: C:\opt\phonegap\scripts\cert\android\dai.keystore Subproject Path: CordovaLib Subproject Path: app > Configure project :app [cordova-plugin-background-fetch] libDir: C:\opt\phonegap\AsistManager\platforms\android\app/libs [cordova-background-geolocation] libDir: C:\opt\phonegap\AsistManager\platforms\android\app/libs [cordova-background-geolocation] playServicesLocationVersion: 20.+ [cordova-background-geolocation] Purging debug resources in release build WARNING:API 'android.registerTransform' is obsolete. It will be removed in version 8.0 of the Android Gradle plugin. The Transform API is removed to improve build performance. Projects that use the Transform API force the Android Gradle plugin to use a less optimized flow for the build that can result in large regressions in build times. ItÆs also difficult to use the Transform API and combine it with other Gradle features; the replacement APIs aim to make it easier to extend the build without introducing performance or correctness issues. There is no single replacement for the Transform APIùthere are new, targeted APIs for each use case. All the replacement APIs are in the `androidComponents {}` block. For more information, see https://developer.android.com/studio/releases/gradle-plugin-api-updates#transform-api. To determine what is calling android.registerTransform, use -Pandroid.debug.obsoleteApi=true on the command line to display more information. --W- The variant: debug, There's no json file --W- The variant: release, There's no json file > Task :app:compileDebugJavaWithJavac Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings BUILD SUCCESSFUL in 1m 2s 50 actionable tasks: 18 executed, 32 up-to-date Built the following apk(s): C:\opt\phonegap\AsistManager\platforms\android\app\build\outputs\apk\debug\app-debug.apk ---------------------------------------------- config.xml (features): config.xml (plugins): ----------------------------------- package.json: { "dependencies": { "cordova-plugin-inappbrowser": "5.0.0" }, "devDependencies": { "@hmscore/cordova-plugin-hms-location": "^6.4.0-300", "at.gofg.sportscomputer.powermanagement": "file:../plugins/at.gofg.sportscomputer.powermanagement", "com.dai.complements": "file:../plugin_daicomplements", "com.dai.plugin.backgroundservice": "file:../plugin_backgroundservice", "com.dai.plugin.backgroundservice.am": "file:../AsistManager_service", "cordova-android": "^11.0.0", "cordova-android-play-services-gradle-release": "^4.0.0", "cordova-background-geolocation-lt": "file:../plugins/cordova-background-geolocation-lt-master", "cordova-device-accounts-v2": "^2.0.8", "cordova-plugin-android-permissions": "^1.1.2", "cordova-plugin-androidx-adapter": "^1.1.3", "cordova-plugin-app-version": "^0.1.12", "cordova-plugin-background-fetch": "^7.1.2", "cordova-plugin-background-mode": "file:../plugins/rammie-cordova-plugin-background-mode", "cordova-plugin-badge": "^0.8.9", "cordova-plugin-badge-fix": "^0.8.10", "cordova-plugin-calendar": "^5.1.5", "cordova-plugin-camera": "^4.1.0", "cordova-plugin-compat": "^1.2.0", "cordova-plugin-device": "^2.1.0", "cordova-plugin-dialogs": "^2.0.2", "cordova-plugin-drawoverapps": "git+https://github.com/ahmedwahba/cordova-plugin-drawoverapps.git", "cordova-plugin-file": "^6.0.2", "cordova-plugin-geolocation": "^4.1.0", "cordova-plugin-googleplus": "^5.3.2", "cordova-plugin-local-notification": "https://github.com/fquirin/cordova-plugin-local-notifications.git", "cordova-plugin-media": "^5.0.3", "cordova-plugin-media-capture": "^3.0.3", "cordova-plugin-network-information": "2.0.2", "cordova-plugin-powermanagement": "^1.0.5", "cordova-plugin-powermanagement-orig": "file:../plugins/cordova-plugin-powermanagement-master", "cordova-plugin-request-location-accuracy": "^2.3.0", "cordova-plugin-splashscreen": "^5.0.4", "cordova-plugin-statusbar": "^2.4.3", "cordova-plugin-tts-advanced": "^0.4.2", "cordova-plugin-vibration": "^3.1.1", "es6-promise-plugin": "^4.2.2", "phonegap-plugin-media-stream": "^1.2.1" }, "cordova": { "plugins": { "cordova-plugin-network-information": {}, "cordova-plugin-googleplus": { "REVERSED_CLIENT_ID": "...", "PLAY_SERVICES_VERSION": "20.+" }, "cordova-plugin-camera": { "ANDROID_SUPPORT_V4_VERSION": "27.+" }, "cordova-plugin-media": {}, "cordova-plugin-splashscreen": {}, "cordova-plugin-statusbar": {}, "cordova-plugin-vibration": {}, "phonegap-plugin-media-stream": {}, "cordova-plugin-media-capture": {}, "at.gofg.sportscomputer.powermanagement": {}, "cordova-plugin-calendar": {}, "cordova-device-accounts-v2": {}, "cordova-android-play-services-gradle-release": { "PLAY-SERVICES-ADS": "20.+", "PLAY-SERVICES-ADS-IDENTIFIER": "20.+", "PLAY-SERVICES-ADS-LITE": "20.+", "PLAY-SERVICES-AFS-NATIVE": "20.+", "PLAY-SERVICES-ANALYTICS": "20.+", "PLAY-SERVICES-ANALYTICS-IMPL": "20.+", "PLAY-SERVICES-APPINVITE": "20.+", "PLAY-SERVICES-AUDIENCE": "20.+", "PLAY-SERVICES-AUTH": "20.+", "PLAY-SERVICES-AUTH-API-PHONE": "20.+", "PLAY-SERVICES-AWARENESS": "20.+", "PLAY-SERVICES-BASE": "20.+", "PLAY-SERVICES-BASEMENT": "20.+", "PLAY-SERVICES-CAST": "20.+", "PLAY-SERVICES-CAST-FRAMEWORK": "20.+", "PLAY-SERVICES-CLEARCUT": "20.+", "PLAY-SERVICES-CRONET": "20.+", "PLAY-SERVICES-DRIVE": "20.+", "PLAY-SERVICES-FIDO": "20.+", "PLAY-SERVICES-FITNESS": "20.+", "PLAY-SERVICES-FLAGS": "20.+", "PLAY-SERVICES-GAMES": "20.+", "PLAY-SERVICES-GASS": "20.+", "PLAY-SERVICES-GCM": "20.+", "PLAY-SERVICES-IDENTITY": "18.+", "PLAY-SERVICES-IID": "20.+", "PLAY-SERVICES-INSTANTAPPS": "20.+", "PLAY-SERVICES-LOCATION": "20.+", "PLAY-SERVICES-MAPS": "20.+", "PLAY-SERVICES-MEASUREMENT": "20.+", "PLAY-SERVICES-MEASUREMENT-API": "20.+", "PLAY-SERVICES-MEASUREMENT-IMPL": "20.+", "PLAY-SERVICES-MEASUREMENT-SDK": "20.+", "PLAY-SERVICES-MEASUREMENT-SDK-API": "20.+", "PLAY-SERVICES-NEARBY": "20.+", "PLAY-SERVICES-OSS-LICENSES": "20.+", "PLAY-SERVICES-PANORAMA": "20.+", "PLAY-SERVICES-PHENOTYPE": "20.+", "PLAY-SERVICES-PLACES": "20.+", "PLAY-SERVICES-PLACES-PLACEREPORT": "20.+", "PLAY-SERVICES-PLUS": "20.+", "PLAY-SERVICES-SAFETYNET": "20.+", "PLAY-SERVICES-STATS": "20.+", "PLAY-SERVICES-TAGMANAGER": "20.+", "PLAY-SERVICES-TAGMANAGER-API": "20.+", "PLAY-SERVICES-TAGMANAGER-V4-IMPL": "20.+", "PLAY-SERVICES-TASKS": "20.+", "PLAY-SERVICES-VISION": "20.+", "PLAY-SERVICES-VISION-COMMON": "20.+", "PLAY-SERVICES-VISION-IMAGE-LABEL": "20.+", "PLAY-SERVICES-WALLET": "20.+", "PLAY-SERVICES-WEARABLE": "20.+" }, "cordova-plugin-request-location-accuracy": { "PLAY_SERVICES_LOCATION_VERSION": "20.+" }, "cordova-plugin-app-version": {}, "cordova-plugin-dialogs": {}, "cordova-plugin-device": {}, "cordova-plugin-android-permissions": {}, "com.dai.complements": {}, "com.dai.plugin.backgroundservice": {}, "com.dai.plugin.backgroundservice.am": {}, "cordova-plugin-tts-advanced": {}, "cordova-plugin-androidx-adapter": {}, "cordova-background-geolocation-lt": { "GOOGLE_API_VERSION": "20.+", "HMS_LOCATION_VERSION": "6.9.0.300", "OKHTTP_VERSION": "3.12.+", "EVENTBUS_VERSION": "3.3.1" }, "cordova-plugin-inappbrowser": {}, "cordova-plugin-background-fetch": {}, "cordova-plugin-powermanagement": {}, "cordova-plugin-hms-location": {}, "cordova-plugin-background-mode": {}, "cordova-plugin-drawoverapps": {}, "cordova-plugin-local-notification": {}, "cordova-plugin-geolocation": { "GPS_REQUIRED": "true" } }, "platforms": [ "android" ] } } ----------------------------------- ```
sebastianlezica commented 12 months ago

By mistake I put config.xml and package.json pointed to two different sources (git master and npm) for cordova-background-geolocation-lt. But the error is the same with both versions. Excuse me.

christocracy commented 12 months ago

What plug-ins is your app using?

sebastianlezica commented 12 months ago

Hi Chris!, I use many because the app do some variable work in the field. The list copied from config.xml is enough?. Or is best copy the package or package-lock.json files?. Please sorry for the inconvenience but really try to solve alone without success...

<plugin name="cordova-plugin-network-information" />
<plugin name="cordova-plugin-googleplus">
    <variable name="REVERSED_CLIENT_ID" value="..." />
</plugin>
<plugin name="cordova-plugin-camera" />
<plugin name="cordova-plugin-media" />
<plugin name="cordova-plugin-splashscreen" />
<plugin name="cordova-plugin-statusbar" />
<plugin name="cordova-plugin-vibration" />
<plugin name="phonegap-plugin-media-stream" />
<plugin name="cordova-plugin-media-capture" />
<plugin name="at.gofg.sportscomputer.powermanagement" spec="C:\opt\phonegap\plugins\cordova-plugin-powermanagement-master" />
<plugin name="cordova-plugin-calendar" />
<plugin name="cordova-plugin-drawoverapps" />
<plugin name="cordova-device-accounts-v2" />
<!-- <plugin name="cordova-background-geolocation-lt" spec="C:\opt\phonegap\plugins\cordova-background-geolocation-lt-master" /> -->
<plugin name="cordova-background-geolocation-lt" source="npm" />
<plugin name="cordova-android-play-services-gradle-release" />
<plugin name="cordova-plugin-request-location-accuracy" />
<plugin name="cordova-plugin-app-version" />
<plugin name="cordova-plugin-dialogs" />
<plugin name="cordova-plugin-device" />
<plugin name="cordova-plugin-android-permissions" />
<plugin name="com.dai.complements" spec="C:\opt\phonegap\plugin_daicomplements" />
<plugin name="cordova-plugin-local-notification" spec="https://github.com/fquirin/cordova-plugin-local-notifications.git" />
<plugin name="com.dai.plugin.backgroundservice" spec="C:\opt\phonegap\plugin_backgroundservice" />
<plugin name="com.dai.plugin.backgroundservice.am" spec="C:\opt\phonegap\AsistManager_service" />
<plugin name="cordova-plugin-tts-advanced" />
christocracy commented 12 months ago

Execute:

$ cordova plugins

Are you aware that Cordova is becoming obsolete? I suggest you migrate to Capacitor asap.

sebastianlezica commented 12 months ago

Initially I think be easier to solve this update (wrong! ;) ), but yes, I must see how to migrate out of Cordova... thanks for the suggestion of Capacitor!.

C:\opt\phonegap\AsistManager>cordova plugins at.gofg.sportscomputer.powermanagement 1.1.2 "PowerManagement" com.dai.complements 1.0.0 "com.dai.complements" com.dai.plugin.backgroundservice.am 2.0.0 "Background Service - AsistManager" com.dai.plugin.backgroundservice 2.0.0 "DAI - Background Service Plugin" cordova-android-play-services-gradle-release 4.0.0 "cordova-android-play-services-gradle-release" cordova-background-geolocation-lt 4.12.0 "BackgroundGeolocation" cordova-device-accounts-v2 2.0.8 "Device Accounts" cordova-plugin-android-permissions 1.1.2 "Permissions" cordova-plugin-androidx-adapter 1.1.3 "cordova-plugin-androidx-adapter" cordova-plugin-app-version 0.1.12 "AppVersion" cordova-plugin-background-fetch 7.1.2 "CDVBackgroundFetch" cordova-plugin-background-mode 0.7.3 "BackgroundMode" cordova-plugin-badge-fix 0.8.10 "Badge" cordova-plugin-calendar 5.1.5 "Calendar" cordova-plugin-camera 4.1.0 "Camera" cordova-plugin-compat 1.2.0 "Compat" cordova-plugin-device 2.1.0 "Device" cordova-plugin-dialogs 2.0.2 "Notification" cordova-plugin-drawoverapps 1.2.1 "Cordova Draw Over Apps" cordova-plugin-file 6.0.2 "File" cordova-plugin-geolocation 4.1.0 "Geolocation" cordova-plugin-googleplus 5.3.2 "Google SignIn" cordova-plugin-hms-location 6.4.0.300 "HMS Location" cordova-plugin-inappbrowser 5.0.0 "InAppBrowser" cordova-plugin-local-notification 0.10.0 "LocalNotification" cordova-plugin-media-capture 3.0.3 "Capture" cordova-plugin-media 5.0.3 "Media" cordova-plugin-network-information 2.0.2 "Network Information" cordova-plugin-powermanagement 1.0.5 "Cordova PowerManagement plugin" cordova-plugin-request-location-accuracy 2.3.0 "Request Location Accuracy" cordova-plugin-splashscreen 5.0.4 "Splashscreen" cordova-plugin-statusbar 2.4.3 "StatusBar" cordova-plugin-tts-advanced 0.4.2 "TTS" cordova-plugin-vibration 3.1.1 "Vibration" es6-promise-plugin 4.2.2 "Promise" phonegap-plugin-media-stream 1.2.1 "MediaStream"

christocracy commented 12 months ago

The plug-in uses an android logging library called slf4j. The version used was recently updated. One of your other plug-ins seems to be using slf4j and pinned to an older version. Let me know which of your other plug-ins is using slf4j.

problems like this (clashing dependency versions like this are solved easily with Capacitor, React Native and Flutter.)

christocracy commented 12 months ago

Your app seems to contain references to PhoneGap. Are you aware that PhoneGap has declared "End of Service"?

sebastianlezica commented 12 months ago

Hi Chris!, I search all, the project and dependencies, and not found any reference for slf4j other than cordova-background-geolocation-lt... And yes, I preserve the folder "phonegap" only because hace older projects and keep the folder structure ;).

Best regards!,

Sebastian Lezica

christocracy commented 12 months ago

I suggest you test with 4.11.2, the version before the slf4j dependency was recently updated.

https://github.com/transistorsoft/cordova-background-geolocation-lt/blob/master/CHANGELOG.md#4113--2023-04-19

sebastianlezica commented 11 months ago

Hi Chris!, Thanks! all work fine with this version, except the android:foregroundServiceType in the ActivityRecognition for the AndroidManifest but solve with edit-config in the build ;). The app keep killed after some time in a couple of devices (the traditional developer fight!), after solve this I try to migrate to Capacitor... I see can use Cordova plugins, your plugin work fine (and I can use my license) or need to buy the new one Capacitor specific?.

Best regards and again thanks for your help!. This plugin is great, my battery consumption down from 30% to 8/10%, and using location everytime. Is not a issue anymore.

Sebastian Lezica