bumptech / bumptech/glide

Unable to load image drawable referred from another xml asset if a public.xml file exists

Open
#5,165 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
35k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
8

Description

**Glide Version**: 4.15.1

**Integration libraries**:

**Device/Android Version**: Nvidia Shield Pro, Google Pixel 7

**Issue details / Repro steps / Use case background**:
This is a tough (and probably very specific) one. I'm building an Android Tv Launcher. I'm loading apps icons (banners) by passing their URI to Glide.
To simplify, Uri is build approximately like this :
```
new Uri.Builder()
.scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(resolveInfo.activityInfo.packageName)
.path(resolveInfo.activityInfo.getBannerResource())
.build();
```

This code is working perfectly : passing this URI to the `load` method of the `RequestManager` does wonders. And worked for thousands of users for a long time... until I found an app that didn't display anything (but was OK on the stock launcher) :
- its icon was not visible in my launcher (="transparent")
- my error drawable was not displayed (as if Glide thought everything was fine on its side)
- no error in the logcat
- onLoadFailed wasn't triggered on a RequestListener

The `banner` in the app's manifest refers to this file `@drawable/banner`
```

```
`mipmap/ic_launcher_banner` is a classic jpg banner.

- Modifying this app through apktool so that the `@drawable/banner` looks like this
```



```
fixes the issue (a red rectlangle is displayed).

- Modifying this app through apktool so that the manifest `banner` refers directly to the `mipmap/ic_launcher_banner` fixes the issue (ic_launcher_banner is displayed).

So I thought the issue was somehow related to the combination of a layer-list referring to another asset reousrce. But copying the *exact* same code/pictures (`drawable/banner` and `mipmap/ic_launcher_banner`) on a test app *is working fine* (in my launcher, Glide is totally capable of loading it).

Long story short, I discovered that the culprit app is using a `values/public.xml` file to assign static ids to drawables.
Recompiling this app with ApkTool *without* the `public.xml` file fixed my issue (the expected icon is displayed, as on the stock launcher)
Note that removing the references to the static ids of `drawable/banner` and `mipmap/ic_launcher_banner` is not sufficient to make Glide load the banner : I have to totally remove the `public.xml` file.

So I interpret the issue like this : if a public.xml file is used, Glide fails to load a bitmaps referred from another xml drawable, but without complaining (so no workaround seems possible on my side to detect such cases).

**Glide load line / `GlideModule` (if any) / list Adapter code (if any)**:
```java
Glide.with(fragment)
.into(new CustomViewTarget(cardView.getMainImageView()) {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition) {
view.setImageDrawable(resource);
}
}
```

**Layout XML**:
```xml

```

**Stack trace / LogCat**: *nothing*

Imagine a grid of icons with a hole where the culprit app lies ;)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.