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

Plugin v 4.16.1 crashed on android: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected #1440

Closed veermaniperen closed 3 weeks ago

veermaniperen commented 3 weeks ago

Your Environment

<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-background-geolocation-lt" version="4.16.1">

<name>BackgroundGeolocation</name>
<description>The most sophisticated, battery-efficient background-geolocation and geofencing plugin for Cordova</description>
<license>MIT</license>
<keywords>cordova, phonegap, background geolocation, background, location, tracking, geofence, geofencing</keywords>

<engines>
    <engine name="cordova" version=">=7.1.0"/>
    <engine name="cordova-android" version=">=7.0.0"/>
    <engine name="cordova-ios" version=">=4.5.0"/>
</engines>

<dependency id="cordova-plugin-background-fetch" version="~7.2.1" />

<js-module src="www/BackgroundGeolocation.js" name="BackgroundGeolocation">
    <clobbers target="window.BackgroundGeolocation" />
</js-module>
<js-module src="www/API.js" name="API"></js-module>
<js-module src="www/DeviceSettings.js" name="DeviceSettings"></js-module>
<js-module src="www/Logger.js" name="Logger"></js-module>
<js-module src="www/TransistorAuthorizationToken.js" name="TransistorAuthorizationToken"></js-module>

<platform name="ios">
    <preference name="BACKGROUND_MODE_LOCATION" default="&lt;string&gt;location&lt;/string&gt;" />

    <!-- required background modes:  App registers for location updates -->
    <config-file target="*-Info.plist" parent="UIBackgroundModes">
        <array>
            $BACKGROUND_MODE_LOCATION
        </array>
    </config-file>

    <config-file target="config.xml" parent="/*">
        <feature name="BackgroundGeolocation">
            <param name="ios-package" value="CDVBackgroundGeolocation"/>
        </feature>
    </config-file>

    <podspec>
        <config>
            <source url="https://cdn.cocoapods.org/"/>
        </config>
        <pods>
            <pod name="CocoaLumberjack" spec="~> 3.7.2" />
        </pods>
    </podspec>

    <framework src="libstdc++.dylib" />
    <framework src="AudioToolbox.framework" weak="true" />
    <framework src="SystemConfiguration.framework" weak="true" />
    <framework src="AVFoundation.framework" weak="true" />
    <framework src="libsqlite3.dylib" weak="true" />
    <framework src="libz.dylib" weak="true" />
    <framework src="src/ios/TSLocationManager.xcframework" custom="true" />
    <source-file src="src/ios/CDVBackgroundGeolocation.m" />
    <header-file src="src/ios/CDVBackgroundGeolocation.h" />

    <!-- background-geolocation -->
    <config-file parent="NSLocationAlwaysAndWhenInUseUsageDescription" target="*-Info.plist">
        <string>Uw locatie gegevens worden bijgehouden wanneer binnen TMS een rit actief is (ook wanneer TMS op de achtergrond draait). Deze gegevens worden centraal opgeslagen, en door de planning gebruikt om in te kunnen spelen op veranderingen.</string>
    </config-file>
    <config-file parent="NSLocationAlwaysUsageDescription" target="*-Info.plist">
        <string>Uw locatie gegevens worden bijgehouden wanneer binnen TMS een rit actief is (ook wanneer TMS op de achtergrond draait). Deze gegevens worden centraal opgeslagen, en door de planning gebruikt om in te kunnen spelen op veranderingen.</string>
    </config-file>
    <config-file parent="NSLocationWhenInUseUsageDescription" target="*-Info.plist">
        <string>Uw locatie gegevens worden bijgehouden wanneer binnen TMS een rit actief is (ook wanneer TMS op de achtergrond draait). Deze gegevens worden centraal opgeslagen, en door de planning gebruikt om in te kunnen spelen op veranderingen.</string>
    </config-file>
    <config-file parent="NSMotionUsageDescription" target="*-Info.plist">
        <string>Uw locatie gegevens worden bijgehouden wanneer binnen TMS een rit actief is (ook wanneer TMS op de achtergrond draait). Deze gegevens worden centraal opgeslagen, en door de planning gebruikt om in te kunnen spelen op veranderingen.</string>
    </config-file>
    <!-- /background-geolocation -->
 </platform>

 <!-- android -->
<platform name="android">
    <preference name="GOOGLE_API_VERSION" default="20.+" />
    <preference name="HMS_LOCATION_VERSION" default="6.9.0.300" />
    <preference name="OKHTTP_VERSION" default="3.12.+" />
    <framework src="com.squareup.okhttp3:okhttp:$OKHTTP_VERSION"/>
    <preference name="EVENTBUS_VERSION" default="3.3.1" />
    <framework src="org.greenrobot:eventbus:$EVENTBUS_VERSION"/>

    <framework src="io.github.nishkarsh:android-permissions:2.1.6"/>
    <framework src="org.slf4j:slf4j-api:2.0.7"/>
    <framework src="com.github.tony19:logback-android:3.0.0"/>
    <framework src="androidx.lifecycle:lifecycle-runtime:2.4.+" />
    <framework src="androidx.lifecycle:lifecycle-extensions:2.2.+" />

    <framework src="src/android/build.gradle" custom="true" type="gradleReference" />

    <resource-file src="src/android/libs/com/transistorsoft/tslocationmanager" target="../../libs/com/transistorsoft/tslocationmanager" />
    <resource-file src="src/android/libs/com/transistorsoft/tslocationmanager-v21" target="../../libs/com/transistorsoft/tslocationmanager-v21" />

    <source-file src="src/android/CDVBackgroundGeolocation.java" target-dir="src/com/transistorsoft/cordova/bggeo" />

    <config-file target="res/xml/config.xml" parent="/*">
        <feature name="BackgroundGeolocation">
            <param name="android-package" value="com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation"/>
        </feature>
    </config-file>

    <config-file parent="/manifest" target="app/src/main/AndroidManifest.xml">
        <uses-permission android:minSdkVersion="34" android:name="android.permission.USE_EXACT_ALARM" />
    </config-file>
    <!-- background-geolocation -->
    <config-file parent="/manifest/application" target="app/src/main/AndroidManifest.xml">
        <meta-data
            android:name="com.transistorsoft.locationmanager.license"
            android:value="*********************************************************" />
    </config-file>
    <!-- /background-geolocation -->
 </platform>

 <!-- Browser (mock) -->
 <platform name="browser">
    <config-file target="config.xml" parent="/*">
        <feature name="BackgroundGeolocation"></feature>
    </config-file>
    <js-module src="src/browser/BackgroundGeolocationMock.js" name="BackgroundGeolocationMock">
        <runs/>
    </js-module>
 </platform>


## Expected Behavior
<!--- Tell us what should happen -->
When our application starts the location service, it should continue as normal.

## Actual Behavior
<!--- Tell us what happens instead -->
The app crashes, in our logging we see te following errormessage:

Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient'


## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context
<!--- What were you trying to do? -->
Make use of the location services

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

```<!-- Syntax highlighting:  DO NOT REMOVE -->
Hard to retrieve from OutSystems, the error that occurs is:

A fatal error has occurred. Please contact OutSystems support: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient'

christocracy commented 3 weeks ago

This is a well known issue due to a breaking change in play-services-location, caused when two different plug-in import the dependency at v20.+ and v21.+

One or your other plug-ins seems to be importing v21.+, so you must use GOOGLE_API_VERSION to align this plugin accordingly (see the readme).

veermaniperen commented 3 weeks ago

Ah okay, I already tried v21.+ but maybe they should be exact, or should be an entirely different version.

I'll see if I can figure out what other plugins are using. Thanks for the hint.

veermaniperen commented 3 weeks ago

Turned out that there was another override in OutSystems that rendered my setting of v21+ useless. Now that I corrected it at the right place, (extensibility configurations of the module in OutSystems) the problem is resolved.

Thank you for your help.