Baseflow / flutter-geolocator

Android and iOS Geolocation plugin for Flutter
https://baseflow.com/
MIT License
1.25k stars 663 forks source link

[Bug] Geolocator Android 13 API 33 precise location does not work #1192

Closed JK-404 closed 1 year ago

JK-404 commented 1 year ago

🐛 Bug Report

With the newest Android Version 13 (API 33) the location accuracy does not work anymore. The user just get the pop up for approximate location. I tested it with Android 12 API 32 and it still work. You get two windows where the user can choose between aproximate and precise location.

Expected behavior

Reproduction steps

  1. call Geolocator.RequestPermission()

Configuration

Android Manifest ACCESS_FINE_LOCATION ACCESS_COARSE_LOCATIOn

Version: 9.0.2

Platform:

JK-404 commented 1 year ago

I cannot exclude that it is due to my own configuration. But please confirm me if it works the plugin for API 33 or not. Thank you very much.

rizaldywirawan commented 1 year ago

Our mobile dev experience the samething, if we downgrade the OS version, it works

DevMayur commented 1 year ago

Do we have any update on android 13 issues ?

daviddagan commented 1 year ago

im getting he location service on the device is disabled in android 13

Kingtous commented 1 year ago

same here, it's really a project blocker.

JK-404 commented 1 year ago

still having the issue..

Kingtous commented 1 year ago

same here, it's really a project blocker.

Maybe getLastKnownPosition can be a fallback.

 Future<Position?> getCurrentLocation({LocationAccuracy? accuracy}) async {
    try {
      var pos = await Geolocator.getCurrentPosition(
          forceAndroidLocationManager: true,
          timeLimit: const Duration(seconds: 5),
          desiredAccuracy: accuracy ?? LocationAccuracy.best);
      return pos;
    } catch (e) {
      debugPrint("$e");
      return Geolocator.getLastKnownPosition(forceAndroidLocationManager: true);
    }
  }
JK-404 commented 1 year ago

I will try later the thing is my customer needs a really precise location because the action he wan'ts to do is only allowed in some areas. But still thank you !

TimHoogstrate commented 1 year ago

Dear @Kampfotter,

Personally I cannot reproduce this issue, can you send me a little more information on how you are testing this. Like e.g. some minimal reproducible code and your configuration settings. An output of flutter doctor -v would also help a lot. Furthermore, can you also confirm that it is working in the example app?

github-actions[bot] commented 1 year ago

Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.

github-actions[bot] commented 1 year ago

Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.

jpunie commented 1 year ago

It seems an permission and SDK version issue on android: https://stackoverflow.com/questions/70793162/android-12-not-showing-correct-permissions-request-screen

adding tools:remove="android:maxSdkVersion" fixed the issue for me. The user will now get the correct dialog with options to opt out of precise location, previously this was not an option.

AntolKun commented 10 months ago

in your app>src>main>AndroidManifest.xml, just use uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="34" , and you'll be fine, tested on INFINIX X663B and Pixel 7 API 34 emulator