bumptech / bumptech/glide

Glide placeholder() and error() with Resource IDs Not Working in On-Demand Module

Open
#5,700 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

When using Glide inside an Android Play Feature Delivery (On-Demand) module, `placeholder()` and `error()` do not display images when a drawable resource ID is passed directly.

### Not Working

```kotlin
Glide.with(context)
.load(imageUrl)
.placeholder(R.drawable.placeholder)
.error(R.drawable.placeholder)
.into(imageView)
```

The image loads correctly when the URL is valid, but the placeholder and error drawables are never displayed.

### Working Alternative

If the drawable is first converted to a `Drawable` object using `AppCompatResources.getDrawable()`, Glide works as expected:

```kotlin
val drawable = AppCompatResources.getDrawable(context, R.drawable.placeholder)

Glide.with(context)
.load(imageUrl)
.placeholder(drawable)
.error(drawable)
.into(imageView)
```

## Environment

* Glide: 5.0.7 (With KSP Compiler)
* Android Gradle Plugin: 9.2.1
* Play Feature Delivery / On-Demand Module

## Expected Behavior

`placeholder(R.drawable.xxx)` and `error(R.drawable.xxx)` should work the same way in an on-demand feature module as they do in the base module.

## Actual Behavior

Resource IDs passed to `placeholder()` and `error()` are ignored or fail to resolve in the on-demand module, while manually resolving the drawable via `AppCompatResources.getDrawable()` works correctly.

## Additional Notes

This issue appears to be specific to Play Feature Delivery (dynamic feature/on-demand) modules. The same code works correctly when placed in the base application module.

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.