No permissions found in manifest for: []22 - Flutter
Asked Answered
M

7

9

I'm trying to get storage permission from the user. Below is the sample (copy-paste) code. But I'm getting error when I'm trying to request the permission.

D/permissions_handler(12775): No permissions found in manifest for: []22

Code

import 'package:duplicate_file_remover/globals.dart' as globals;
import 'package:duplicate_file_remover/ui/views/homeViews/homeView.dart';
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:permission_handler/permission_handler.dart';

class MainDataProvider extends StatefulWidget {
  const MainDataProvider({Key? key}) : super(key: key);

  @override
  _MainDataProviderState createState() => _MainDataProviderState();
}

class _MainDataProviderState extends State<MainDataProvider> {

  PermissionStatus _permissionStatus = PermissionStatus.denied;

  Future<void> _askStoragePermission() async {
    debugPrint(" ---------------- Asking for permission...");
    await Permission.manageExternalStorage.request();
    if (await Permission.manageExternalStorage.request().isGranted) {
      PermissionStatus permissionStatus =
          await Permission.manageExternalStorage.status;
      setState(() {
        _permissionStatus = permissionStatus;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: TextButton(
          onPressed: () async {
            await _askStoragePermission();

            if (_permissionStatus.isGranted) {
              debugPrint(" ---------------- Permission allowed");
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => HomeView(),
                ),
              );
            } else {
              // openAppSettings();
              debugPrint(" --------------------- Permission denied");
            }
          },
          child: const Text("Get permission"),
        ),
      ),
    );
  }
}

I'm using permission_handler (https://pub.dev/packages/permission_handler) package.

I tried this solutions but it is not working.

Malawi answered 18/2, 2022 at 20:53 Comment(0)
F
4

Check your targetSdkVersion in build.gradle file.

If you are using Android 11 (targetSdkVersion = 30), you will need to write this permission in manifest differently. You can try the solution discussed in this post

Flemish answered 17/3, 2022 at 2:15 Comment(0)
S
3

For people how experienced the issue also,

Add this permission in your manifest file under <Manifest tag

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
Shaunda answered 13/10, 2022 at 11:41 Comment(0)
M
1
Map<Permission, PermissionStatus> statuses = await [
  Permission.storage,
  Permission.manageExternalStorage,
].request();

var storage = statuses[Permission.storage];
var manageExternalStorage = statuses[Permission.manageExternalStorage];
if (storage.isGranted || manageExternalStorage.isGranted) {
  // do something
}
Mattern answered 16/6, 2023 at 4:2 Comment(2)
You should add explanation.Gulch
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Anthea
S
0

I was going through the same issue. It looks like the file_picker handles the STORAGE permission itself. So you don't need to ask this permission separately. Just use the pickFile() function directly and the plugin will handle the rest. Hope it helps

Showman answered 7/2, 2024 at 8:8 Comment(0)
E
0

Underlying problem here could be the storage permission change Android did after v13. So application code will need to support both permission types.

First manifest file

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Then a code like below handle both flows like Even Cai has shared in their answer.

import 'package:permission_handler/permission_handler.dart';

class PermissionUtil {
  static Future<bool> tryPermission(Permission permission) async {
    var status = await permission.request();
    if (status != null) {
      if (status.isGranted) {
        print('granted');
        return true;
      } else if (status.isDenied) {
        print('requesting permission');
        status = await Permission.manageExternalStorage.request();
        if (status.isGranted) {
          print('newly granted');
          return true;
        } else {
          print('User denied ${permission.runtimeType} request'); // @fixme generalize
        }
      } else if (status.isPermanentlyDenied) {
        print('permanently denied');
      }
    }
    return false;
  }
}


// usage
bool permitted = await PermissionUtil.tryPermission(Permission.storage) || await PermissionUtil.tryPermission(Permission.manageExternalStorage); // for android <13 and 13+
// end
Encumbrance answered 19/2, 2024 at 21:23 Comment(0)
E
0

For Android, I added this to my androidManifest.xml file and it seemed to work:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" /> <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

Although I found out there might be issues while uploading on Play Store. I am open to better ways of doing this.

Enchanter answered 2/8, 2024 at 4:32 Comment(0)
D
-1

I have the same error, I solved it by creating a new flutter project and copy my code to the new

Donall answered 1/5, 2022 at 16:4 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.