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

Library not working on Android Q (API 29) #33

Open
akrezic1 opened this issue Jun 6, 2019 · 12 comments
Open

Library not working on Android Q (API 29) #33

akrezic1 opened this issue Jun 6, 2019 · 12 comments

Comments

@akrezic1
Copy link

akrezic1 commented Jun 6, 2019

There is an issue with permissions because of Scoped Storage and it's giving this stacktrace:

java.io.FileNotFoundException: /storage/emulated/0/DCIM/Camera/IMG_20190606_105527.jpg: open failed: EACCES (Permission denied) at libcore.io.IoBridge.open(IoBridge.java:496) at java.io.RandomAccessFile.<init>(RandomAccessFile.java:289) at com.bumptech.glide.util.ByteBufferUtil.fromFile(ByteBufferUtil.java:43) at com.bumptech.glide.load.model.ByteBufferFileLoader$ByteBufferFetcher.loadData(ByteBufferFileLoader.java:65) at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:62) at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:302) at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:272) at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:233) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919) at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446) Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied) at libcore.io.Linux.open(Native Method) at libcore.io.ForwardingOs.open(ForwardingOs.java:167) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252) at libcore.io.ForwardingOs.open(ForwardingOs.java:167) at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7218) at libcore.io.IoBridge.open(IoBridge.java:482) at java.io.RandomAccessFile.<init>(RandomAccessFile.java:289)  at com.bumptech.glide.util.ByteBufferUtil.fromFile(ByteBufferUtil.java:43)  at com.bumptech.glide.load.model.ByteBufferFileLoader$ByteBufferFetcher.loadData(ByteBufferFileLoader.java:65)  at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:62)  at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:302)  at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:272)  at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:233)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)  at java.lang.Thread.run(Thread.java:919)  at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446) 

Tested on Android Studio 3.5 Beta 3 with Pixel 3 API 29 emulator. To test it you need to set compileSdkVersion and targetSdkVersion to 29.

@siralam
Copy link
Owner

siralam commented Jun 7, 2019

Guess for now you would have to lower the target SDK version, but I will make it in the future version. Thanks for the report!

@barnhill
Copy link

Ran into this myself. You can get around this by feeding glide the Uri instead of the path

@sjd753
Copy link

sjd753 commented Oct 3, 2019

Having the same issue here. when are you going to fix it for Q api 29?
what else can be done to get around it?

Ran into this myself. You can get around this by feeding glide the Uri instead of the path

how to do this?

@barnhill
Copy link

barnhill commented Oct 3, 2019

It's one of the overloaded methods ... Can't remember off the top of my head. Make sure you use the latest glide too.

@yesidlazaro
Copy link

hi, any progress here?

@engr-erum
Copy link

Hi , Any progress for Android Q ?

@siralam
Copy link
Owner

siralam commented Jan 16, 2020

Sorry guys I have been quite busy recently, but I will try to get this done this month. If not this month may be in Februaray then.

@bemrePG
Copy link

bemrePG commented Jan 16, 2020

Ran into this myself. You can get around this by feeding glide the Uri instead of the path

Hi, just tried it with passing the uri. Still doesn't work. Any workaround for the mean time?

@siralam
Copy link
Owner

siralam commented Jan 17, 2020

Hey guys, simply by adding android:requestLegacyExternalStorage="true" to your <application> tag in AndroidManifest should fix the problem for now. Anyone tried?

@bemrePG
Copy link

bemrePG commented Jan 17, 2020

Hi, works great! Thank you very much.

@siralam
Copy link
Owner

siralam commented Jan 21, 2020

Guys, yesterday I spent quite some time looking into this and I still cannot find a way to do it perfectly in all versions. I think there are still quite a lack of resources about this topic in the community, and even the Android documentation has not updated yet 🤷‍♂

So for now I decided to just leave it as the original way and just use android:requestLegacyExternalStorage="true".

@siralam siralam mentioned this issue May 11, 2020
@Greger34
Copy link

Seems to work fine with glide.

    @Override
    public void loadImage(Uri imageUri, ImageView ivImage)
    {
        Glide.with(this).load(imageUri).into(ivImage);
    }

but you need to do some magic in public void onSingleImageSelected(Uri uri, String tag) to be able to do something with the image afterwards. Mainly copying the image to local cache using file descriptor. You can read more about it here:
https://medium.com/@sriramaripirala/android-10-open-failed-eacces-permission-denied-da8b630a89df

After doing those things it works as intended for me without needing the android:requestLegacyExternalStorage="true"

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

No branches or pull requests

8 participants