Almoullim / background_location

Flutter background location plugin for Android and iOS
https://pub.dev/packages/background_location
Other
224 stars 236 forks source link

Error java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.FusedLocationProviderClient #178

Closed abedputra closed 1 year ago

abedputra commented 1 year ago

I just found an error like this when running my App

D/AndroidRuntime(16579): Shutting down VM
E/AndroidRuntime(16579): FATAL EXCEPTION: main
E/AndroidRuntime(16579): 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/~~KvMgk1xXU1Va-RNufrd5Fg==/com.my.ientry.mypersonal.system-xXn3QY3cUGgQp0Z-wJ0ZFw==/base.apk)
E/AndroidRuntime(16579):        at com.almoullim.background_location.LocationUpdatesService.getLastLocation(LocationUpdatesService.kt:188)
E/AndroidRuntime(16579):        at com.almoullim.background_location.LocationUpdatesService.onCreate(LocationUpdatesService.kt:125)
E/AndroidRuntime(16579):        at android.app.ActivityThread.handleCreateService(ActivityThread.java:4648)
E/AndroidRuntime(16579):        at android.app.ActivityThread.access$1900(ActivityThread.java:275)
E/AndroidRuntime(16579):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2187)
E/AndroidRuntime(16579):        at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(16579):        at android.os.Looper.loopOnce(Looper.java:210)
E/AndroidRuntime(16579):        at android.os.Looper.loop(Looper.java:299)
E/AndroidRuntime(16579):        at android.app.ActivityThread.main(ActivityThread.java:8280)
E/AndroidRuntime(16579):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(16579):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
E/AndroidRuntime(16579):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1073)
W/personal.system(16579): type=1400 audit(0.0:31782): avc: denied { search } for name="mqsas" dev="mmcblk0p46" ino=1294337 scontext=u:r:untrusted_app:s0:c46,c257,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.my.ientry.mypersonal.system
W/personal.system(16579): type=1400 audit(0.0:31783): avc: denied { search } for name="mqsas" dev="mmcblk0p46" ino=1294337 scontext=u:r:untrusted_app:s0:c46,c257,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.my.ientry.mypersonal.system
W/personal.system(16579): type=1400 audit(0.0:31784): avc: denied { search } for name="mqsas" dev="mmcblk0p46" ino=1294337 scontext=u:r:untrusted_app:s0:c46,c257,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.my.ientry.mypersonal.system
W/OOMEventManagerFK(16579): Failed to mkdir /data/mqsas/hprof/
W/personal.system(16579): type=1400 audit(0.0:31785): avc: denied { search } for name="mqsas" dev="mmcblk0p46" ino=1294337 scontext=u:r:untrusted_app:s0:c46,c257,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.my.ientry.mypersonal.system
W/personal.system(16579): type=1400 audit(0.0:31786): avc: denied { getattr } for path="/data/mqsas" dev="mmcblk0p46" ino=1294337 scontext=u:r:untrusted_app:s0:c46,c257,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.my.ientry.mypersonal.system
W/personal.system(16579): type=1400 audit(0.0:31787): avc: denied { search } for name="mqsas" dev="mmcblk0p46" ino=1294337 scontext=u:r:untrusted_app:s0:c46,c257,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.my.ientry.mypersonal.system
I/Process (16579): Sending signal. PID: 16579 SIG: 9
Lost connection to device.

How to fix it yea?

abedputra commented 1 year ago

I think this package conflicts with the geolocator package. When I comment on the geolocator in the .yml file then this app works well.

isaacfi commented 1 year ago

This is an issue only on Android and it is caused by and upgrade on play-services-location with breakup changes for 21.0.0 and above on geolocator_android dependency. The workaround to avoid this is override the dependency with geolocator_android to force the use of 20.0.0.

com.google.android.gms:play-services-location:20.0.0

The only needed is to modify the pubspec.yaml on your project with:

dependency_overrides:
  geolocator_android: "4.1.4"

BR.