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
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:
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.
When using Glide inside an Android Play Feature Delivery (On-Demand) module,
placeholder()anderror()do not display images when a drawable resource ID is passed directly.Not Working
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
Drawableobject usingAppCompatResources.getDrawable(), Glide works as expected:Environment
Expected Behavior
placeholder(R.drawable.xxx)anderror(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()anderror()are ignored or fail to resolve in the on-demand module, while manually resolving the drawable viaAppCompatResources.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.