'No permissions found in manifest for: []22 - Flutter

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.



Solution 1:[1]

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

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jiachenxu
Solution 2