3

I don't know what changes make it. I guess it start with flutter upgrade from 3.3.5 to 3.7.0. I spent all day long with this problem. Downgrade not work. Project clean not work. New git checkout and build not work.

Here was an answer on react native. Some version of google play services has known issue about. But I didn't found to fix version of google play service on flutter.

class was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient') in react native

E/AndroidRuntime(18632): FATAL EXCEPTION: main
E/AndroidRuntime(18632): Process: com.vendict.vendict_for_nfc, PID: 18632
E/AndroidRuntime(18632): 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/~~gKUrnUKImAp2nfFppEkQjw==/com.vendict.vendict_for_nfc-s_CcDEKjsiyAuJc2YQz-8A==/base.apk)
E/AndroidRuntime(18632):    at com.naver.maps.map.util.FusedLocationSource$b$1.onConnected(SourceFile:123)
E/AndroidRuntime(18632):    at com.google.android.gms.common.internal.zak.zad(com.google.android.gms:play-services-base@@18.1.0:11)
E/AndroidRuntime(18632):    at com.google.android.gms.common.api.internal.zabe.zab(com.google.android.gms:play-services-base@@18.1.0:3)
E/AndroidRuntime(18632):    at com.google.android.gms.common.api.internal.zaaw.zaC(com.google.android.gms:play-services-base@@18.1.0:11)
E/AndroidRuntime(18632):    at com.google.android.gms.common.api.internal.zaaw.zag(com.google.android.gms:play-services-base@@18.1.0:4)
E/AndroidRuntime(18632):    at com.google.android.gms.common.api.internal.zabi.onConnected(com.google.android.gms:play-services-base@@18.1.0:2)
E/AndroidRuntime(18632):    at com.google.android.gms.common.api.internal.zat.onConnected(com.google.android.gms:play-services-base@@18.1.0:1)
E/AndroidRuntime(18632):    at com.google.android.gms.common.internal.zah.onConnected(com.google.android.gms:play-services-base@@18.1.0:1)
E/AndroidRuntime(18632):    at com.google.android.gms.common.internal.zzf.zzd(com.google.android.gms:play-services-basement@@18.1.0:10)
E/AndroidRuntime(18632):    at com.google.android.gms.common.internal.zza.zza(com.google.android.gms:play-services-basement@@18.1.0:4)
E/AndroidRuntime(18632):    at com.google.android.gms.common.internal.zzc.zze(com.google.android.gms:play-services-basement@@18.1.0:3)
E/AndroidRuntime(18632):    at com.google.android.gms.common.internal.zzb.handleMessage(com.google.android.gms:play-services-basement@@18.1.0:31)
E/AndroidRuntime(18632):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(18632):    at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(18632):    at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(18632):    at android.app.ActivityThread.main(ActivityThread.java:7842)
E/AndroidRuntime(18632):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18632):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(18632):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
seung hwan Son
  • 183
  • 1
  • 7
  • Did you set the google play services version to 20 as mentioned in the linked question? – Ozan Taskiran Jan 27 '23 at 11:30
  • Yes as link ext.googlePlayServicesVersion = '21.0.1' but not effected. How to fix google play services version in Flutter? – seung hwan Son Jan 28 '23 at 01:59
  • 1
    I have the same problem as well. I have tried everything but no luck. – Chongju Mai Jan 29 '23 at 17:53
  • https://docs.flutter.dev/development/add-to-app/android/plugin-setup#c-merging-libraries tell if dependency not matched between project and package, gradle resolve conflict by newest version. I added 21.0.1 in my android app build.gradle. But error message is same. I remove flutter directory and reinstall flutter now. – seung hwan Son Jan 30 '23 at 01:03
  • @ChongjuMai Try my case. – seung hwan Son Jan 30 '23 at 08:39
  • Please do not edit solution announcements into the question. Accept (i.e. click the "tick" next to it) one of the existing answer, if there are any. You can also create your own answer, and even accept it, if your solution is not yet covered by an existing answer. Compare https://stackoverflow.com/help/self-answer – Yunnosch Jan 30 '23 at 08:40
  • @seunghwanSon Can you give me more information on how to downgrade it? – Chongju Mai Jan 30 '23 at 17:32
  • @ChongjuMai In your project's pubspec.lock file, find package you want to downgrade and change version and "flutter pub get". That's all. – seung hwan Son Jan 31 '23 at 00:17
  • @seunghwanSon How did you ping point which two libraries have the version conflict? – Chongju Mai Jan 31 '23 at 02:52

1 Answers1

2

In my case two packages were use different version of "google play services location package". One use 18.0.0 and another use 21.0.1(Which was updated recently.). https://docs.flutter.dev/development/add-to-app/android/plugin-setup#c-merging-libraries tell me gradle how to resolve two packages which use same package but not same version. I downgrade package which use 21.0.1 to 18.0.0 and work fine.

seung hwan Son
  • 183
  • 1
  • 7