Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.2.0] Permission.photos.status always returns PermissionStatus.denied on Android 12 #944

Closed
MinseokKang003 opened this issue Oct 21, 2022 · 25 comments · Fixed by #1195
Closed
Labels
P2 Important issues not at the top of the work list. platform: android Issue is related to the Android platform. platform: android 12 type: documentation Update to the documentation type: enhancement New feature or request

Comments

@MinseokKang003
Copy link

🔙 Regression

Old (and correct) behavior

Permission.photos.status returns PermissionStatus.granted on Android 12

Current behavior

Permission.photos.status always returns PermissionStatus.denied on Android 12

Reproduction steps

Call Permission.photos.status on Android 12

Configuration

Properly setup AndroidManifest.xml.
It worked well on 10.1.0.

Version:
10.1.0 -> 10.2.0

@MinseokKang003 MinseokKang003 changed the title Permission.photos.status always returns PermissionStatus.denied on Android 12 [10.2.0] Permission.photos.status always returns PermissionStatus.denied on Android 12 Oct 21, 2022
@MinseokKang003
Copy link
Author

Needs to be fixed, it works properly as soon as I downgrade permission_handler and permission_handler_android to 10.1.0.

@caihua
Copy link

caihua commented Oct 24, 2022

same question

@caihua
Copy link

caihua commented Oct 24, 2022

2395c10#r87752291
No permissions found in manifest for: []9
I found this maybe error.


 if (names.isEmpty()) {
  Log.d(PermissionConstants.LOG_TAG, "No permissions found in manifest for: " + permission + " no need to show request rationale");
  successCallback.onSuccess(false);
  return;
}

 static List<String> getManifestNames(Context context, @PermissionConstants.PermissionGroup int permission) {
        final ArrayList<String> permissionNames = new ArrayList<>();

        switch (permission) {
 case PermissionConstants.PERMISSION_GROUP_PHOTOS:
                // The READ_MEDIA_IMAGES permission is introduced in Android T, meaning we should
                // not handle permissions on pre Android T devices.   
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && hasPermissionInManifest(context, permissionNames, Manifest.permission.READ_MEDIA_IMAGES ))
                    permissionNames.add(Manifest.permission.READ_MEDIA_IMAGES);
                break;

@hinrikHelga
Copy link

2395c10#r87752291 No permissions found in manifest for: []9 I found this maybe error.


 if (names.isEmpty()) {
  Log.d(PermissionConstants.LOG_TAG, "No permissions found in manifest for: " + permission + " no need to show request rationale");
  successCallback.onSuccess(false);
  return;
}

 static List<String> getManifestNames(Context context, @PermissionConstants.PermissionGroup int permission) {
        final ArrayList<String> permissionNames = new ArrayList<>();

        switch (permission) {
 case PermissionConstants.PERMISSION_GROUP_PHOTOS:
                // The READ_MEDIA_IMAGES permission is introduced in Android T, meaning we should
                // not handle permissions on pre Android T devices.   
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && hasPermissionInManifest(context, permissionNames, Manifest.permission.READ_MEDIA_IMAGES ))
                    permissionNames.add(Manifest.permission.READ_MEDIA_IMAGES);
                break;

I've been experiencing exactly this issue for Android versions 12.0 and before. Works fine on Android 13.0.

Any idea of how to solve this or a workaround?

@NaosFr
Copy link

NaosFr commented Oct 25, 2022

Same problem

@TillCity
Copy link

I ran into the issue with Permissions.photos.status always returning PermissionStatus.denied today for no reason that is immediately obvious to me though I suppose the Flutter upgrades and the upgrade of the image_picker plugin may have a role to play there. I have fixed this by checking Permissions.storage.status instead and ensuring that that permission has been granted. While this works it is not clear to me what Permissions.photos does if Permissions.storage works to let me have access to the image gallery on the device

@dr953
Copy link

dr953 commented Oct 25, 2022

Same problem here

@hinrikHelga
Copy link

hinrikHelga commented Oct 25, 2022

I ran into the issue with Permissions.photos.status always returning PermissionStatus.denied today for no reason that is immediately obvious to me though I suppose the Flutter upgrades and the upgrade of the image_picker plugin may have a role to play there. I have fixed this by checking Permissions.storage.status instead and ensuring that that permission has been granted. While this works it is not clear to me what Permissions.photos does if Permissions.storage works to let me have access to the image gallery on the device

I've fixed this by checking for Permissions.storage.status when the device is Android 12.0 or below, else I use the Permissions.photos.status. I use the device_info_plus plugin to check the Android version.

I added the following to my AndroidManifest.kt

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="32"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>

and in flutter:

if (Platform.isAndroid) {
  final androidInfo = await DeviceInfoPlugin().androidInfo;
  if (androidInfo.version.sdkInt <= 32) {
    /// use [Permissions.storage.status]
  }  else {
    /// use [Permissions.photos.status]
  }
}

@ehangwork
Copy link

Same question

@oscarshaitan
Copy link

I spot that the version 10.0.0 works only if I set the android version to 10.0.0 too
permission_handler: 10.0.0
permission_handler_android: 10.0.0
If I leave only the handler the pubspeck.lock will pull the android 10.2.0 that fails

@mujahid008
Copy link

Same is happening with me on Android 11

@Alpha17-2
Copy link

Alpha17-2 commented Nov 3, 2022

I ran into the issue with Permissions.photos.status always returning PermissionStatus.denied today for no reason that is immediately obvious to me though I suppose the Flutter upgrades and the upgrade of the image_picker plugin may have a role to play there. I have fixed this by checking Permissions.storage.status instead and ensuring that that permission has been granted. While this works it is not clear to me what Permissions.photos does if Permissions.storage works to let me have access to the image gallery on the device

I've fixed this by checking for Permissions.storage.status when the device is Android 12.0 or below, else I use the Permissions.storage.status. I use the device_info_plus plugin to check the Android version.

I added the following to my AndroidManifest.kt

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="32"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>

and in flutter:

if (Platform.isAndroid) {
  final androidInfo = await DeviceInfoPlugin().androidInfo;
  if (androidInfo.version.sdkInt <= 32) {
    /// use [Permissions.storage.status]
  }  else {
    /// use [Permissions.photos.status]
  }
}

Until they fix this, i guess we have to work with @hinrikHelga solution.

@lg8294
Copy link

lg8294 commented Feb 22, 2023

same question

@seceba
Copy link

seceba commented Feb 23, 2023

Android 11 and Android 13 works but android 12 ( sdk 31 ) problem still exist.

@alfietapping
Copy link

alfietapping commented Mar 7, 2023

I ran into the issue with Permissions.photos.status always returning PermissionStatus.denied today for no reason that is immediately obvious to me though I suppose the Flutter upgrades and the upgrade of the image_picker plugin may have a role to play there. I have fixed this by checking Permissions.storage.status instead and ensuring that that permission has been granted. While this works it is not clear to me what Permissions.photos does if Permissions.storage works to let me have access to the image gallery on the device

I've fixed this by checking for Permissions.storage.status when the device is Android 12.0 or below, else I use the Permissions.storage.status. I use the device_info_plus plugin to check the Android version.
I added the following to my AndroidManifest.kt

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="32"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>

and in flutter:

if (Platform.isAndroid) {
  final androidInfo = await DeviceInfoPlugin().androidInfo;
  if (androidInfo.version.sdkInt <= 32) {
    /// use [Permissions.storage.status]
  }  else {
    /// use [Permissions.photos.status]
  }
}

Until they fix this, i guess we have to work with @hinrikHelga solution.

Tried this on android 13 & 11, neither currently working. Using permission_handler: ^10.2.0 and targeting api 33

@oscarshaitan
Copy link

any update or fix?

@QPAYRE
Copy link

QPAYRE commented Apr 18, 2023

Got the same issue .

@hinrikHelga 's solution worked for me. Thanks

@ardeshir-33033
Copy link

I hope this gets a fix since some packages like Agora use this version of the Permission handler so we cannot downgrade it.

@jdevp
Copy link

jdevp commented May 2, 2023

Tried @hinrikHelga solution but didn't get rid of " No permissions found in manifest for: []9". Permission.photos is always denied. Running Android 12 and target 31.

@wojciechzahradnikdeviniti

Hi, any updates on this issue? I still have a problem with that.

@JDongKhan
Copy link

JDongKhan commented Jun 30, 2023

bluetoothConnect & bluetoothScan has same issue

@carman247
Copy link

Is there any workaround for this currently?

@dehypnosis
Copy link

dehypnosis commented Jul 7, 2023

@carman247 as far as I know, 10.1.0 is latest working version.

@dehypnosis
Copy link

dehypnosis commented Aug 19, 2023

No progress...? I cannot upgrade this lib since this issue happened.
If photos status won't support backward-compatibility for under Android Tiramisu version.
Users always need to check android version by self.

@TimHoogstrate TimHoogstrate added the platform: android Issue is related to the Android platform. label Aug 23, 2023
@TimHoogstrate
Copy link
Contributor

According to the documentation: https://developer.android.com/about/versions/14/changes/partial-photo-video-access and https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions you need to grand permissions to access photos on Android 13 and higher.

Android 12 and lower need to grand different permissions like readExternalStorage and writeExternalStorage to access photos.

I don't think this is a bug in the permission handler. It is also not introduced in 10.1.0. Support for Android 13 was introduced by ADDING permissions for photo's. I have to test the behaviour on Android 12 and below, but it seems to work as expected.

I'll discuss within the team to see if this is something we would like to change in the future or if we need to add additional documentation to make things clear. Either way, it would be an enhancement. The solution of @hinrikHelga would be the way to go until further notice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Important issues not at the top of the work list. platform: android Issue is related to the Android platform. platform: android 12 type: documentation Update to the documentation type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.