I try to request permissions to use location data with a flutter app. I am using the geolocator plugin and permission_handler. Both added to my pubspec.yaml
.
I have futhermore added
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
to my android/app/src/main/AndroidManifest.xml
.
The first thing I do when I launch my app, is
PermissionHandler().requestPermissions([PermissionGroup.location]).then((val) {
...
});
If I then run this on either an emulator or on my physical phone, it returns a PermissionStatus.unknown
and subsequent calls to GeoLocator()
spams the console with
No permissions found in manifest for: $permission
If I go into app-settings it says that no special permissions were requested.
When I then open up the exact same project as an Android project (I am using Android Studio for both, there is a neat dropdown option to open Android project in Android Studio) and run it on my phone it works as expected - it asks for the permission and if I go into the app-settings I can also see the requested permission there.
Anyone have any idea why it does not get "propagated" with flutter?
It seems like the main issue is that the AndroidManifest.xml is not updated when simply relaunching the application. If, however, one first do a flutter clean
and then rebuilds it, the AndroidManifest.xml is updated.
I am not sure if this the intended behavior, but it works. Just something to remember.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With