miguelpruivo/flutter_file_picker

Permission Error in Android Version 13.

Closed this issue · 15 comments

In my project, I am using the file_picker package for picking files. It still works perfectly in Android 12 and below. However, when I change my app's target version to 33, which is Android 13, it stops working and gives me an error:

PlatformException: PlatfomException(read_external_storage_denied, User did not allow reading external storage, null, null)

I have included all the required permissions in my manifest file, but I am still encountering this error. Additionally, in the app info, I am not seeing any requested permission for storage. This issue is specific to Android 13.

Since android13, the READ_EXTERNAL_STORAGE permission is no longer valid, you need to apply for READ_MEDIA_**.
Alternatively, it is possible to apply for the MANAGE_EXTERNAL_STORAGE permission directly, although this is not a good idea.

@twinkles-twinstar I used MANAGE_EXTERNAL_STORAGE permission but its still not working as expected.

i am also facing the same issue in my flutter project

i am also facing the same issue in my flutter project

Did you found any solution to this ?

@twinkles-twinstar I used MANAGE_EXTERNAL_STORAGE permission but its still not working as expected.

Have you requested the MANAGE_EXTERNAL_STORAGE permission for your app and granted it at runtime?
I don’t know the details of file_picker. For the android side, I did not use file_picker, but wrote MethodChannel myself. You can take a look at my code MainActivity.kt.
It works perfectly on Android 12 (my phone) and Android 13 (WSA emulator), requires MANAGE_EXTERNAL_STORAGE permission.
(Note: It is inconsistent with the behavior of file_picker, my code will try to resolve the uri to an absolute path, and only copy to the fallback directory if it cannot be resolved.)

i have give the MANAGE_EXTERNAL_STORAGE permission but it does not work and check the permission is granted as well.

@twinkles-twinstar Didn't get it bro, can you simplify. I have requested MANAGE_EXTERNAL_STORAGE as well.

i have give the MANAGE_EXTERNAL_STORAGE permission but it does not work and check the permission is granted as well.

I am facing excatly same issue.

This issue is stale because it has been open for 14 days with no activity.

So how did all the Guys ultimately solve this problem?

This issue is stale because it has been open for 14 days with no activity.

This seems a bit strange. . . flutter_file_picker seems to only report permission errors when sdk<33. FilePickerDelegate.java
On Android 13, this exception seems like it shouldn't occur.
Did you just change the target sdk = android13, but run your app on the android12 device, or did you change the target sdk and use the android13 device to run the app?

I'm not the developer of this plugin, so it doesn't seem to solve your problem. My solution is to write my own methodchannel, you can check out my project:
Kotlin
Dart

This is a very simple implementation, just declare the permissions in the manifest, then call checkStoragePermission/requestStoragePermission and finally call the pickPath function, it works fine on my device.

So how did all the Guys ultimately solve this problem?

@sxzhangdashen Didn't find any exact solution yet.

This issue is stale because it has been open for 14 days with no activity.

This issue was closed because it has been inactive for 14 days since being marked as stale.