简体   繁体   中英

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.

截屏

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.

检查 targetSdkVersion 是否为 23 如果是,则检查运行时权限您可以使用checkSelfPermission()requestPermissions() for android 6 及更高版本

open android project in flutterProject

click manifests file

insert permission

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

1. Add them in AndroidMenifest.xml

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="30"></uses-permission>
<uses-permission android:name="com.google.android.gms.permission.AD_ID"></uses-permission>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"></uses-permission>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"></uses-permission>
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"></uses-permission>

2. Update permissions handler package:

Package link: https://pub.dev/packages/permission_handler

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM