android-multipicker-library icon indicating copy to clipboard operation
android-multipicker-library copied to clipboard

API 30 Problem with permission when trying select image from gallery

Open angryNerdPN opened this issue 3 years ago • 7 comments

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.

angryNerdPN avatar Jun 10 '21 11:06 angryNerdPN

I am facing the same problem with my android 11 devices. Is there any fix on this that will be helpful?

mkathiravan avatar Jun 15 '21 14:06 mkathiravan

One quick fix of this issue we need to target our android version 29 instead of 30 then the gallery part will work

mkathiravan avatar Jun 15 '21 15:06 mkathiravan

@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!

rubapigh avatar Aug 17 '21 14:08 rubapigh

Hello @mkathiravan @rubapigh @angryNerdPN
Have you found a solution for this problem?

philippeehlert avatar Oct 06 '21 17:10 philippeehlert

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)"

rubapigh avatar Oct 06 '21 17:10 rubapigh

Hello @rubapigh thank you for your prompt answer, we will try this solution

philippeehlert avatar Oct 06 '21 18:10 philippeehlert

Hello @rubapigh! Just to let you know that this change fixed the error. Selecting image from gallery works now.

Thank you again!

philippeehlert avatar Oct 07 '21 13:10 philippeehlert