java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected
Can someone help me with this?? Android 11 (R) API 30 Pixel 4
D/FlutterGeolocator(12490): Attaching Geolocator to activity
D/FlutterGeolocator(12490): Creating service.
D/FlutterGeolocator(12490): Binding to location service.
E/AndroidRuntime(12490): FATAL EXCEPTION: main
E/AndroidRuntime(12490): Process: com.dashfuel.app, PID: 12490
E/AndroidRuntime(12490): java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.FusedLocationProviderClient, but class was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient' appears in /data/app/~~KPtYTQeobzWgbpitvR1gRA==/com.dashfuel.app-6WlMr0kIASZp6YLXPNnv2g==/base.apk)
E/AndroidRuntime(12490): at com.transistorsoft.locationmanager.location.TSLocationManager.removeLocationUpdates(Unknown Source:41)
E/AndroidRuntime(12490): at com.transistorsoft.locationmanager.location.TSLocationManager.stopUpdatingLocation(Unknown Source:0)
E/AndroidRuntime(12490): at com.transistorsoft.locationmanager.location.TSLocationManager.stop(Unknown Source:0)
E/AndroidRuntime(12490): at com.transistorsoft.locationmanager.service.TrackingService.stop(Unknown Source:100)
E/AndroidRuntime(12490): at com.transistorsoft.locationmanager.adapter.TSConfig$c$a.a(Unknown Source:63)
E/AndroidRuntime(12490): at com.transistorsoft.locationmanager.lifecycle.LifecycleManager.e(Unknown Source:39)
E/AndroidRuntime(12490): at com.transistorsoft.locationmanager.lifecycle.LifecycleManager.onStart(Unknown Source:46)
E/AndroidRuntime(12490): at androidx.lifecycle.FullLifecycleObserverAdapter.onStateChanged(FullLifecycleObserverAdapter.java:39)
E/AndroidRuntime(12490): at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:360)
E/AndroidRuntime(12490): at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:202)
E/AndroidRuntime(12490): at com.transistorsoft.locationmanager.lifecycle.LifecycleManager.run(Unknown Source:8)
E/AndroidRuntime(12490): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(12490): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(12490): at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime(12490): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime(12490): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(12490): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime(12490): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
See the CHANGELOG at v4.8.2:
play-services:location has introduced a breaking change in v21, breaking the plugin. playServicesLocationVersion will be capped with a maximum of v20. The next major release (4.10.0) will set a minimum required version of v21.
You cannot use playServicesLocationVersion > 20.0.0 currently
I am not using v21

One of your other plugins is.
Run ./gradlew app:dependencies to see which:
$ cd android
$ ./gradlew app:dependencies
Not all plugins expose a handy ext.playServicesLocationVersion to that developers can conveniently control dependency version. Most simply hard-code the version within the plugin's own build.gradle file!
Like geolocator, for example.
I can easily release a version compiled for playServicesLocationVersion >= v21. But once I do, one will have to make sure all their other plugins importing play-services-location are compatible with v21 as well.
@christocracy it was this package https://pub.dev/packages/geolocator/versions/8.2.1, i removed it because i dont need it anymore. Thank you!
I ran the command ./gradlew app:dependencies and got the following output
-
project :flutter_background_geolocation | +--- com.transistorsoft:tslocationmanager:+ -> 3.2.10 | +--- com.google.android.gms:play-services-location:20.0.0 (*)
-
project :geolocator_android | +--- com.google.android.gms:play-services-location:20.0.0 | | +--- com.google.android.gms:play-services-base:18.0.1
both packages are using the same googlePlayServicesLocationVersion
One of your plugins is using v21
search using this filter -> com.google.android.gms:play-services-location:21.0.0 and no results
That wouldn’t capture 21.0.1 (the latest version).
I have same experience with plugin:
geolocator_android
I resolved it by forcing:
dependency_overrides:
geolocator: 9.0.1
geolocator_android: 4.1.4
They changed to API 21 in version 4.1.7. This is no issue of geolocation plugin.
Three days ago, the people over at geolocator_android naively accepted a pull-request bumping their hard-coded play-services:location version to v21 and released it to a point release 4.1.6, rather than a major version bump (eg: 4.2.0).
I let them know they're causing havoc at the pull-request where this change was accepted.
Thanks @christocracy !
I'll be releasing a v4.9.0 here next week with play-services:location @ v21. it's not a difficult task and I've been aware of this since October. I just wasn't counting on it being forced upon me by some other plugin's point-release.
It's just that when one does so, one will have to make sure all their other modules using play-services:location are @ v21+ as well (eg: map components, etc).
This all could have been avoided at flutter_geolocator had they implemented a Gradle Configuration Variable ext.playServicesLocationVersion, as done here, instead of a hard-coded version.
geolocator_android
thank you for that i had to do a lot of research to know this
I'm working on compiling two separate version of tslocationmanager.aar (one for v20 and another for v21).
The plugin's build.gradle will detect your configured ext.playServicesLocationVersion and import the corresponding tsloctionmanager.aar.
v4.9.0 is now released with play-services-location support for v21
v4.9.0 is now released with play-services-location support for v21 i updated to v490 but my app still crashes with geolocator:9.0.2 and geolocator_android: 4.1.7 same exception. to continue i used dependency_overrides: geolocator: 9.0.1 geolocator_android: 4.1.4
Observe your ./gradlew app:dependencies
Observe your
./gradlew app:dependencies
i forgot to set ext.playServicesLocationVersion in build.gradle, thanks for the quick reply.
I faced the same issue cause I upgraded geoLocator to v9.0.2 which uses googlePlayServicesLocationVersion v21 and flutter_background_geolocation uses v20
So, I solved it by downgrade geoLocator to v8.2.1 in pubspec.yaml