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

Can't load resource drawable Uri if drawable is a vector #2137

Closed
gajicm93 opened this issue Jul 13, 2017 · 5 comments
Closed

Can't load resource drawable Uri if drawable is a vector #2137

gajicm93 opened this issue Jul 13, 2017 · 5 comments

Comments

@gajicm93
Copy link

Glide Version: 4.0.0-RC1
Integration libraries: okhttp3-4.0.0-RC1
Device/Android Version: Nexus 5X 7.1.2

Issue details / Repro steps / Use case background:

Loading an Uri pointing to a resource drawable "android.resource://package/drawable/ic_facebook" fails if the drawable is a Vector. Works fine otherwise, so that is definitely the problem.

Stack trace / LogCat:

07-13 13:35:47.132 23478-23478/package W/Glide: Load failed for android.resource://package/drawable/ic_facebook with size [189x189]
                                                               class com.bumptech.glide.load.engine.GlideException: Failed to load resource
                                                                 Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{AssetInputStream->Bitmap->Bitmap}, LOCAL
                                                                   Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{AssetInputStream->Bitmap->Bitmap}
                                                                 Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class android.os.ParcelFileDescriptor, LOCAL
                                                                   Cause (1 of 1): class java.io.FileNotFoundException: Resource does not exist: android.resource://package/drawable/ic_facebook
07-13 13:35:47.132 23478-23478/package E/Glide: class com.bumptech.glide.load.engine.GlideException: Failed to load resource
07-13 13:35:47.134 23478-23478/package I/Glide: Root cause (1 of 1)
                                                               java.io.FileNotFoundException: Resource does not exist: android.resource://package/drawable/ic_facebook
                                                                   at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:976)
                                                                   at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:907)
                                                                   at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:21)
                                                                   at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:13)
                                                                   at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:40)
                                                                   at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
                                                                   at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:282)
                                                                   at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:398)
                                                                   at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:359)
                                                                   at com.bumptech.glide.load.engine.SourceGenerator.onDataReady(SourceGenerator.java:111)
                                                                   at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:48)
                                                                   at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
                                                                   at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:282)
                                                                   at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:252)
                                                                   at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:222)
                                                                   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                   at java.lang.Thread.run(Thread.java:761)
                                                                   at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:347)

@humblerookie
Copy link

humblerookie commented Aug 5, 2017

Getting this error too on an emulator for Pixel XL. Any update on this guys?

@Gounlaf
Copy link

Gounlaf commented Aug 16, 2017

Is a shape a vector?
Because I got same error when I load an xml drawable (a shape). I own the drawable (not from another library)

@klinker41
Copy link

I'm seeing an error similar to this as well, except it is happening for Android Oreo's adaptive icons (defined similarly to vectors and shapes in an xml):

Root cause (1 of 1)
java.io.FileNotFoundException: Resource does not exist: android.resource://com.android.chrome/2130837809
    at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1239)
    at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1170)
    at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:21)
    at com.bumptech.glide.load.data.FileDescriptorLocalUriFetcher.loadResource(FileDescriptorLocalUriFetcher.java:13)
    at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:40)
    at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:95)
    at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
    at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:282)
    at com.bumptech.glide.load.engine.DecodeJob.decodeFromRetrievedData(DecodeJob.java:398)
    at com.bumptech.glide.load.engine.DecodeJob.onDataFetcherReady(DecodeJob.java:359)
    at com.bumptech.glide.load.engine.SourceGenerator.onDataReady(SourceGenerator.java:111)
    at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onDataReady(MultiModelLoader.java:129)
    at com.bumptech.glide.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:48)
    at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:95)
    at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
    at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:282)
    at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:252)
    at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:222)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:764)
    at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:347)

Normal icons seem to be working as expected (tested with Uber, which does not support an adaptive icon yet).

@wardellbagby
Copy link

It looks like the issue is that load just doesn't like VectorDrawables. Looking at #1532, it turns out just doing

GlideApp.with(context).load(null).fallback(R.drawable.my_vector).into(imageView)

will work fine. Yes, it has to be GlideApp, which means you need to implement a GlideAppModule, which is pretty simple. You can do that by creating a file with these contents:

@GlideModule
public final class MyAppGlideModule extends AppGlideModule {}

For more information about the GlideAppModule and the generated API, check http://bumptech.github.io/glide/doc/generatedapi.html

sjudd added a commit to sjudd/glide that referenced this issue Oct 7, 2017
As a fallback for drawables that we either can’t obtain an InputStream
for or can’t decode as Bitmaps, Glide will now also call 
Resources#getDrawable with the given resource id. 

Fixes bumptech#2137.
sjudd added a commit to sjudd/glide that referenced this issue Oct 7, 2017
As a fallback for drawables that we either can’t obtain an InputStream
for or can’t decode as Bitmaps, Glide will now also call 
Resources#getDrawable with the given resource id. 

Fixes bumptech#2137.
@sjudd
Copy link
Collaborator

sjudd commented Oct 7, 2017

Actually this is a duplicate of #350.

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

7 participants