3

After stopping myself from asking this question for a week, here I am. I've been trying to resolve the no permission issue of Android. I've developed this app with Flutter and have uploaded it to play store for open testing. But, in release mode, it just never asks for permission. Just never. No message or log in console/logcat.

I've tried using two-three packages of flutter for the same but none worked. It works flawlessly in debug mode, the permission pop-up comes, you allow it and functions work as they should be. In case of release build, the pop-up doesn't come. When you check app's permissions settings, you see that the permission has been auto-denied every time in every device in Android 7.0, 8.0, 10 (not tried in others). Even after allowing the permission from settings, it doesn't work and permission gets denied again.

Code I've used:

  1. With permission package :

    var permissionStatus =
        await Permission.getPermissionsStatus([PermissionName.Storage]);
    print(permissionStatus.toString());
    if (permissionStatus.first.permissionStatus == PermissionStatus.allow) {
      _saveFile();
    } else {
      var permissions =
          await Permission.requestPermissions([PermissionName.Storage]);
      print(permissions.first.permissionStatus.toString());
      if (permissions.first.permissionStatus == PermissionStatus.allow)
        _saveFile();
      else
        Fluttertoast.showToast(
            msg: "Storage permission required to share!",
            toastLength: Toast.LENGTH_LONG,
            gravity: ToastGravity.BOTTOM,
            timeInSecForIosWeb: 2,
            backgroundColor: greyColor,
            textColor: Colors.white,
            fontSize: 16.0);
    }
    
  2. With permission_handler package :

    if (await permissionsService.hasStoragePermission()) {
       print("Saving file");
      _saveFile();
    } else {
    final PermissionHandler _permissionHandler = PermissionHandler();
    
    var permission =
      Platform.isAndroid ? PermissionGroup.storage : PermissionGroup.photos;
    var result = await _permissionHandler.requestPermissions([permission]);
    
    if (result[permission] == PermissionStatus.granted)
       _saveFile();
    else
      Fluttertoast.showToast(
        msg: "Storage permission required to share!",
        toastLength: Toast.LENGTH_LONG,
        gravity: ToastGravity.BOTTOM,
        timeInSecForIosWeb: 2,
        backgroundColor: greyColor,
        textColor: Colors.white,
        fontSize: 16.0);
    

I've also tried using Permission Service.

I found similar question with no answer here - Flutter app wont ask for Storage permission in release mode

My app has already been delayed by Google play Store by taking 16 days to verify, please provide a solution so I can avoid further delay. And No, the flutter clean doesn't help.

EDIT - Searching for more packages for permission handling on pub.dev, I found permission_plugin which also doesn't work, same issue but it gives an error in logcat.

The error -

2020-10-02 23:54:44.289 16214-16260/? E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(171)] Unhandled Exception:
    MissingPluginException(No implementation found for method check-permissions on channel permissions_plugin)
#0  MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157)
    <asynchronous suspension>
#1  PermissionsPlugin.checkPermissions (package:permissions_plugin/permissions_plugin.dart:69)
    <asynchronous suspension>
#2   _CertificateState._saveImage (package:app_name/screens/app_screen.dart:211)
    <asynchronous suspension>

Update : This error comes with other permission packages as well. Now, I believe this is the cause of the problem. I'll share any piece of code required.

Lalit Fauzdar
  • 5,953
  • 2
  • 26
  • 50
  • I wrote the answer to this question here: https://stackoverflow.com/a/64235971/2025941 – Alex Oct 07 '20 at 23:21
  • Answer to this question in a related stack overflow post: https://stackoverflow.com/a/64235971/2025941 – Alex Oct 07 '20 at 23:22
  • Thanks, @Alex but I've found the solution 3 days ago after looking at almost everywhere for an answer. The solution was to create a new project and copy the code in it. As I looked more, I believe this problem occurs when you change the channel to stable from master as also mentioned in your answer. – Lalit Fauzdar Oct 08 '20 at 06:16

3 Answers3

1

I've solved this problem by creating a new project and copying the code in it. This suggestion was found on a similar issue of Official Flutter Github Repo. I believe this happens because of changing the channel to stable from master as discussed in that issue thread but changing it back again doesn't solve the problem. I also looked everywhere related to the plugin exception but no answer/solution worked.

This bug/issue should really be looked upon by the developers.

Lalit Fauzdar
  • 5,953
  • 2
  • 26
  • 50
  • 1
    This actually worked........ i went to and back from dev to stable a few times, i never thought it would cause problems. Copying files on a new project fixed the issue for me – M.M.Hasibuzzaman Oct 31 '20 at 08:47
0

Have you added the below code to android manifest file?

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Abhishek Ghaskata
  • 1,802
  • 2
  • 6
  • 11
0

I also had the same problem and Couldn`t find a solution but when I tried to lower the API of my android simulator, from 30 API to 28 API it suddenly works.