question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API 30 Problem with permission when trying select image from gallery

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

4reactions
rubapighcommented, 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)"

0reactions
philippeehlertcommented, Oct 7, 2021

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

Thank you again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Permissions related error in Android API level 30 #776 - GitHub
I know this is working great till API Level 29 but in latest API level 30 - I see error after taking picture...
Read more >
API 30 Problem with permission when trying select image from ...
API 30 Problem with permission when trying select image from gallery.
Read more >
Query all images from phone works on api 18 but not on api 30
Solution was by asking for permissions again at runtime so that is my code that worked for me after reading the following tutorial...
Read more >
Permissions updates in Android 11 - Android Developers
Starting in Android 11, whenever your app requests a permission related to location, microphone, or camera, the user-facing permissions dialog contains an ...
Read more >
Accessing the Camera and Stored Media - CodePath Cliffnotes
The easy way - launch the camera with an intent, designating a file path, and handle the onActivityResult. · The hard way -...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found