rekabhq / background_locator

A Flutter plugin for updating location in background.
MIT License
288 stars 328 forks source link

[Android] Fatal exception: AbstractMethodError: android.location.LocationListener.onProviderDisabled/onProviderEnabled #241

Closed Saxorman closed 3 years ago

Saxorman commented 3 years ago

Hello! When the background service starts and location tracking is turned off - the application exits with a fatal error. Either the state was switched while the service was running - the same result.

E/AndroidRuntime(23214): FATAL EXCEPTION: main
E/AndroidRuntime(23214): Process: xx.xx.xx.xx, PID: 23214
E/AndroidRuntime(23214): java.lang.AbstractMethodError: abstract method "void android.location.LocationListener.onProviderDisabled(java.lang.String)"
E/AndroidRuntime(23214):    at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:367)
E/AndroidRuntime(23214):    at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:277)
E/AndroidRuntime(23214):    at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:293)
E/AndroidRuntime(23214):    at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(23214):    at android.os.Looper.loop(Looper.java:224)
E/AndroidRuntime(23214):    at android.app.ActivityThread.main(ActivityThread.java:7562)
E/AndroidRuntime(23214):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(23214):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/AndroidRuntime(23214):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

https://github.com/rekab-app/background_locator/blob/master/android/src/main/kotlin/rekab/app/background_locator/provider/AndroidLocationProviderClient.kt If override these functions (onProviderDisabled/onProviderEnabled), then the problem disappears and goes away and you can switch location tracking painlessly.

Version package: 1.5.0+1 (this is also applicable to the latest version, but there are problems with it that have already been discussed here)

compileSdkVersion/targetSdkVersion: 30

Tested on real device with 30 api and emulators with 22, 23, 24, 25 versions of api.

=========

This behavior is observed with LocationClient.android. With LocationClient.google - all ok.

mehdok commented 3 years ago

Hi @Saxorman Thank you for opening an issue, and thank you for pointing to the solution;

244

zy693415 commented 2 years ago

hi ,android 26 27 , This kind of error happens again