androidxmlflutter

No permissions found in Manifest [Android]


I have been trying various ways to call on my location data ranging from IP location API's to Flutter plugin's but have not been able to get accurate location data for any of them. Through all I have settled onto Geolocator. But I kept getting

I/flutter ( 5206): null
I/flutter ( 5206): GeolocationStatus.unknown

When calling it in my Init state as follows:

  void initState() {
    super.initState();
    fetchData();
  }


  fetchData() async {
    setState(() {
      isLoading = true; //Data is loading
    });
    GeolocationStatus geolocationStatus =
        await Geolocator().checkGeolocationPermissionStatus();
    position = await Geolocator()
        .getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
    if (position != null) {
      lastPosition = await Geolocator()
          .getLastKnownPosition(desiredAccuracy: LocationAccuracy.high);
    }

    ...

    if (position != null)
      print(position);
    else
      print(lastPosition);

    print(geolocationStatus);

    setState(() {
      isLoading = false; //Data has loaded
    });
  }

After some research I decided to settle on permission_handler to try to check permissions. I declared PermissionStatus _status added the following lines to my fetchData() function:

PermissionHandler()
        .checkPermissionStatus(PermissionGroup.location);

To which I get No permissions found in manifest for: 3 My manifest has the permissions to the best of my understanding. Manifest file: https://gist.github.com/Purukitto/640d1637c05bdb1b69cc4309947c45d5

From what I understand adding the permissions to the Manifest should add the permission option at least to the app, but after building and installing the app there are "No permissions" for my app(Screenshot attached).

What could be the problem. I have tried to mention all relevant things. Any insight will be really helpful.

Screenshot


Solution

  • This question is linked in the Flutter package permission_handler's ReadMe as an example of setting up the AndroidManifest.xml for asking permissions.

    If you're having issues with the device asking the user for permissions, this may be your culprit.

    To elaborate on rollcake's answer:
    1. If you don't know what permissions you need yet, go to the Android Developer page to see the list and the syntax(es).
    2. In your project, open: android/app/src/main/AndroidManifest.xml
    3. Insert your permissions as shown in this example here:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.your.package">
    
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    
        <application
            android:name="io.flutter.app.FlutterApplication"
            ...<and so on>...
    

    Just a side note: There are different AndroidManifest.xml files in your project (...src/debug, ...src/profile, and ...src/main). Adding the permissions to the main version described above should work but if you're noticing inconsistent behavior make sure you're putting all of your permissions in the same AndroidManifest file.