tlserver / flutter_map_location_marker

A flutter map plugin for displaying device current location.
https://pub.dev/packages/flutter_map_location_marker
BSD 3-Clause "New" or "Revised" License
102 stars 93 forks source link

Granting only coarse location causes crash #122

Open Finni123 opened 3 months ago

Finni123 commented 3 months ago

Describe the bug When I request location permission and only coarse location is granted, the app crashes. Nothing in my app uses location except for the location marker plugin, so it seems to be the cause.

To Reproduce Steps to reproduce the behavior:

  1. Create FlutterMap with a CurrentLocationLayer child
  2. Request Location permission (on Android)
  3. Grant Approximate / coarse location only
  4. App crashes

Expected behavior The map and this plugin should still work but show location with low precision, or no location.

Environment

Error

E/AndroidRuntime(27264): FATAL EXCEPTION: main
E/AndroidRuntime(27264): Process: com.xyz.abc, PID: 27264
E/AndroidRuntime(27264): java.lang.SecurityException: Neither user 10575 nor current process has android.permission.ACCESS_FINE_LOCATION.
E/AndroidRuntime(27264):    at android.os.Parcel.createExceptionOrNull(Parcel.java:3182)
E/AndroidRuntime(27264):    at android.os.Parcel.createException(Parcel.java:3166)
E/AndroidRuntime(27264):    at android.os.Parcel.readException(Parcel.java:3149)
E/AndroidRuntime(27264):    at android.os.Parcel.readException(Parcel.java:3091)
E/AndroidRuntime(27264):    at android.location.ILocationManager$Stub$Proxy.registerGnssNmeaCallback(ILocationManager.java:1622)
E/AndroidRuntime(27264):    at android.location.LocationManager$GnssNmeaTransportManager.registerTransport(LocationManager.java:3109)
E/AndroidRuntime(27264):    at android.location.LocationManager$GnssNmeaTransportManager.registerTransport(LocationManager.java:3099)
E/AndroidRuntime(27264):    at com.android.internal.listeners.ListenerTransportManager.addListener(ListenerTransportManager.java:70)
E/AndroidRuntime(27264):    at android.location.LocationManager.addNmeaListener(LocationManager.java:2611)
E/AndroidRuntime(27264):    at android.location.LocationManager.addNmeaListener(LocationManager.java:2592)
E/AndroidRuntime(27264):    at com.baseflow.geolocator.location.NmeaClient.start(NmeaClient.java:76)
E/AndroidRuntime(27264):    at com.baseflow.geolocator.location.FusedLocationClient.requestPositionUpdates(FusedLocationClient.java:157)
E/AndroidRuntime(27264):    at com.baseflow.geolocator.location.FusedLocationClient.lambda$startPositionUpdates$2$com-baseflow-geolocator-location-FusedLocationClient(FusedLocationClient.java:240)
E/AndroidRuntime(27264):    at com.baseflow.geolocator.location.FusedLocationClient$$ExternalSyntheticLambda1.onSuccess(D8$$SyntheticClass:0)
E/AndroidRuntime(27264):    at com.google.android.gms.tasks.zzm.run(com.google.android.gms:play-services-tasks@@18.1.0:1)
E/AndroidRuntime(27264):    at android.os.Handler.handleCallback(Handler.java:959)
E/AndroidRuntime(27264):    at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime(27264):    at android.os.Looper.loopOnce(Looper.java:232)
E/AndroidRuntime(27264):    at android.os.Looper.loop(Looper.java:317)
E/AndroidRuntime(27264):    at android.app.ActivityThread.main(ActivityThread.java:8501)
E/AndroidRuntime(27264):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(27264):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
E/AndroidRuntime(27264):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
E/AndroidRuntime(27264): Caused by: android.os.RemoteException: Remote stack trace:
E/AndroidRuntime(27264):    at android.app.ContextImpl.enforce(ContextImpl.java:2333)
E/AndroidRuntime(27264):    at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:2361)
E/AndroidRuntime(27264):    at com.android.server.location.gnss.GnssManagerService.registerGnssNmeaCallback(GnssManagerService.java:191)
E/AndroidRuntime(27264):    at com.android.server.location.LocationManagerService.registerGnssNmeaCallback(LocationManagerService.java:1087)
E/AndroidRuntime(27264):    at android.location.ILocationManager$Stub.onTransact(ILocationManager.java:806)

Possible solution The error I get looks very similar to the error in this discussion, so I think maybe the solution from that thread should be applied to this plugin.

tlserver commented 3 months ago

Wondering this is an issue in geolocator or not. Since the call stack show that it is from com.baseflow.geolocator.location.NmeaClient.start(NmeaClient.java:76).

github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

tlserver commented 1 month ago

Sorry, I cannot repoduce this issue. Does your problem still exist in current version?

github-actions[bot] commented 1 week ago

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.