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

API 30 Problem with permission when trying select image from gallery #186

Open
angryNerdPN opened this issue Jun 10, 2021 · 7 comments
Open

Comments

@angryNerdPN
Copy link

angryNerdPN commented Jun 10, 2021

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.

@mkathiravan
Copy link

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

@mkathiravan
Copy link

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

@rubapigh
Copy link

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

@philippeehlert
Copy link

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

@rubapigh
Copy link

rubapigh commented Oct 6, 2021

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

@philippeehlert
Copy link

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

@philippeehlert
Copy link

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

Thank you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants