Dev-hwang / flutter_activity_recognition

This plugin is used to recognize user activity on Android and iOS platforms.
https://pub.dev/packages/flutter_activity_recognition
MIT License
13 stars 12 forks source link

java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.ActivityRecognitionClient, but class was expected (declaration of 'com.google.android.gms.location.ActivityRecognitionClient' #2

Closed flodaniel closed 1 year ago

flodaniel commented 1 year ago

I see the following crash as soon as i try to use the plugin:

java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.ActivityRecognitionClient, but class was expected (declaration of 'com.google.android.gms.location.ActivityRecognitionClient'

I am running the latest plugin version with these android sdk settings:

compileSdkVersion 33
targetSdkVersion 33
minSdkVersion 23

Trying to upgrade my google play services location to this, did also not work:

    implementation "com.google.android.gms:play-services-location:21.0.1"

is there any way to resolve this?

flodaniel commented 1 year ago

I managed to resolve it by downgrading the version to 20. Ideally we can upgrade the plugin to work with version 21.

Flajt commented 1 year ago

Mhmm... the same issue here, on a different plugin a similar error appeared, where the issue was a rework of the API. See: Lyokone/flutterlocation#810 The link posted there to the Google Blog thing also mentions a rework of the ActivityApi if I read it correctly.

I consider forking it, but my android developer skills are rather limited rn.

AdmiJW commented 1 year ago

I also have the same issue in my project that uses geolocator and this flutter_activity_recognition package. In my attempt to solve this issue, I created an entirely new project that contains only example code from flutter_activity_recognition and it works perfectly fine. Still, as soon as I include geolocator in my project, it quickly ran into this error on the app startup. That's when I knew there were some incompatibility issues between these 2 packages.

Then, I see this Github Issue, and this solved everything for me.

Samuel-ML commented 1 year ago

same error

Flajt commented 1 year ago

I've forked it and changed the version code of the native Code and it works for now. You could try using it, by calling it from github directly.

Dev-hwang commented 1 year ago

check flutter_activity_recognition: ^2.0.0