android-multipicker-library
android-multipicker-library copied to clipboard
API 30 Problem with permission when trying select image from gallery
When an app is targeting SDK 30 the problem occurs. Library throws exception while selecting image from gallery.
com.kbeanie.multipicker.api.exceptions.PickerException: java.io.FileNotFoundException: /storage/emulated/0/.../IMG_20210608_12494-2.jpg: open failed: EPERM (Operation not permitted)
... - rest of folder path
Capture image via Camera or record video still working.
I am facing the same problem with my android 11 devices. Is there any fix on this that will be helpful?
One quick fix of this issue we need to target our android version 29 instead of 30 then the gallery part will work
@mkathiravan I have the same problem on android 11 devices... but the play store now not allow upload new versions without targetSdkVersion 30. Could you find any solution with target SDK 30. Thank you!
Hello @mkathiravan @rubapigh @angryNerdPN
Have you found a solution for this problem?
Hi @philippeehlert.
Yes thanks to @matale I found next solution:
"Seems to work if you set the caching method as INTERNAL_APP_DIR. The default and other options seem to check for WRITE EXTERNAL STORAGE permission which you will not have in Android 30.
The issue is that in Android 30 there is no more permission to write to external storage, even if declared it does nothing unless your App has the MANAGE_EXTERNAL_STORAGE permission which is will require manual approval of your App, you will not get this approval in most cases.
While you always have access to internal App storage no permission necessary.
So when you create the picker set the Cache.
val picker = MediaPicker(this) picker.setCacheLocation(CacheLocation.INTERNAL_APP_DIR)"
Hello @rubapigh thank you for your prompt answer, we will try this solution
Hello @rubapigh! Just to let you know that this change fixed the error. Selecting image from gallery works now.
Thank you again!