<p dir="auto"><strong>Glide Version</strong>: com.github.bumptech.glide:glide:4.2.0</p>

<p dir="auto"><strong>Integration libraries</strong>: No</p>

<p dir="auto"><strong>Device/Android Version</strong>: Samsung</p>
<p dir="auto"><strong>What happened</strong><br>
I want to load gif images that stored locally. I get the drawable based on the name of the file. when try to load with glide it's crash with the logcat below.</p>
<ul dir="auto">
<li>
<p dir="auto">If i access to the file with R.drawable.anygif then it's working fine.</p>
</li>
<li>
<p dir="auto">With GlideApp.load(getDrawable(mContext, "filename")), In the logcat it says Failed to find any ModelLoaders for model BitmapDrawable, but BitmapDrawable is a subclass of Drawable then it would be better if this can be load as well.</p>
</li>
<li>
<p dir="auto">With GlideApp.load(getDrawable(mContext, "filename")), If i use it in placeholder then gif not working ( just an image ).</p>
</li>
</ul>
<p dir="auto">Any idea?</p>

<p dir="auto"><strong>Glide load line / <code class="notranslate">GlideModule</code> (if any) / list Adapter code (if any)</strong>:<br>
<strong>Working</strong></p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="GlideApp.with(mContext)
                        .load(R.drawable.anygif)
                        .override(320)
                        .diskCacheStrategy(DiskCacheStrategy.DATA)
                        .placeholder(R.mipmap.placeholder)
                        .into(fakePageVH.mImgSticker);"><pre class="notranslate"><span class="pl-smi">GlideApp</span>.<span class="pl-en">with</span>(<span class="pl-s1">mContext</span>)
                        .<span class="pl-en">load</span>(<span class="pl-smi">R</span>.<span class="pl-s1">drawable</span>.<span class="pl-s1">anygif</span>)
                        .<span class="pl-en">override</span>(<span class="pl-c1">320</span>)
                        .<span class="pl-en">diskCacheStrategy</span>(<span class="pl-smi">DiskCacheStrategy</span>.<span class="pl-c1">DATA</span>)
                        .<span class="pl-en">placeholder</span>(<span class="pl-smi">R</span>.<span class="pl-s1">mipmap</span>.<span class="pl-s1">placeholder</span>)
                        .<span class="pl-en">into</span>(<span class="pl-s1">fakePageVH</span>.<span class="pl-s1">mImgSticker</span>);</pre></div>
<p dir="auto"><strong>Not Working</strong></p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="GlideApp.with(mContext)
                        .load(getDrawable(mContext, &quot;filename&quot;))
                        .override(320)
                        .diskCacheStrategy(DiskCacheStrategy.DATA)
                        .placeholder(R.mipmap.ic_launcher_round)
                        .into(fakePageVH.mImgSticker);"><pre class="notranslate"><span class="pl-smi">GlideApp</span>.<span class="pl-en">with</span>(<span class="pl-s1">mContext</span>)
                        .<span class="pl-en">load</span>(<span class="pl-en">getDrawable</span>(<span class="pl-s1">mContext</span>, <span class="pl-s">"filename"</span>))
                        .<span class="pl-en">override</span>(<span class="pl-c1">320</span>)
                        .<span class="pl-en">diskCacheStrategy</span>(<span class="pl-smi">DiskCacheStrategy</span>.<span class="pl-c1">DATA</span>)
                        .<span class="pl-en">placeholder</span>(<span class="pl-smi">R</span>.<span class="pl-s1">mipmap</span>.<span class="pl-s1">ic_launcher_round</span>)
                        .<span class="pl-en">into</span>(<span class="pl-s1">fakePageVH</span>.<span class="pl-s1">mImgSticker</span>);</pre></div>
<p dir="auto"><strong>Working but gif not play, just an image</strong></p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="GlideApp.with(mContext)
                        .load(&quot;&quot;)
                        .override(320)
                        .diskCacheStrategy(DiskCacheStrategy.DATA)
                        .placeholder(getDrawable(mContext, &quot;filename&quot;))
                        .into(fakePageVH.mImgSticker);"><pre class="notranslate"><span class="pl-smi">GlideApp</span>.<span class="pl-en">with</span>(<span class="pl-s1">mContext</span>)
                        .<span class="pl-en">load</span>(<span class="pl-s">""</span>)
                        .<span class="pl-en">override</span>(<span class="pl-c1">320</span>)
                        .<span class="pl-en">diskCacheStrategy</span>(<span class="pl-smi">DiskCacheStrategy</span>.<span class="pl-c1">DATA</span>)
                        .<span class="pl-en">placeholder</span>(<span class="pl-en">getDrawable</span>(<span class="pl-s1">mContext</span>, <span class="pl-s">"filename"</span>))
                        .<span class="pl-en">into</span>(<span class="pl-s1">fakePageVH</span>.<span class="pl-s1">mImgSticker</span>);</pre></div>
<p dir="auto"><strong>Helper</strong></p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="public static Drawable getDrawable(Context context, String ImageName) {
        return ContextCompat.getDrawable(context, context.getResources().getIdentifier(ImageName, &quot;drawable&quot;, context.getPackageName()));
    }"><pre class="notranslate"><span class="pl-k">public</span> <span class="pl-k">static</span> <span class="pl-smi">Drawable</span> <span class="pl-s1">getDrawable</span>(<span class="pl-smi">Context</span> <span class="pl-s1">context</span>, <span class="pl-smi">String</span> <span class="pl-s1">ImageName</span>) {
        <span class="pl-k">return</span> <span class="pl-smi">ContextCompat</span>.<span class="pl-en">getDrawable</span>(<span class="pl-s1">context</span>, <span class="pl-s1">context</span>.<span class="pl-en">getResources</span>().<span class="pl-en">getIdentifier</span>(<span class="pl-s1">ImageName</span>, <span class="pl-s">"drawable"</span>, <span class="pl-s1">context</span>.<span class="pl-en">getPackageName</span>()));
    }</pre></div>

<p dir="auto"><strong>Stack trace / LogCat</strong>:</p>
<div class="highlight highlight-source-ruby notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="com.bumptech.glide.Registry$NoModelLoaderAvailableException: Failed to find any ModelLoaders for model: android.graphics.drawable.BitmapDrawable@ad5185c
                                                                             at com.bumptech.glide.Registry.getModelLoaders(Registry.java:543)
                                                                             at com.bumptech.glide.load.engine.DecodeHelper.getLoadData(DecodeHelper.java:186)
                                                                             at com.bumptech.glide.load.engine.DecodeHelper.getCacheKeys(DecodeHelper.java:204)
                                                                             at com.bumptech.glide.load.engine.DataCacheGenerator.&lt;init&gt;(DataCacheGenerator.java:33)
                                                                             at com.bumptech.glide.load.engine.DecodeJob.getNextGenerator(DecodeJob.java:278)
                                                                             at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:259)
                                                                             at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:230)
                                                                             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:762)
                                                                             at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:386)"><pre class="notranslate"><span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">Registry</span>$NoModelLoaderAvailableException: <span class="pl-en">Failed</span> <span class="pl-en">to</span> <span class="pl-en">find</span> <span class="pl-en">any</span> <span class="pl-v">ModelLoaders</span> <span class="pl-k">for</span> <span class="pl-en">model</span>: <span class="pl-en">android</span><span class="pl-kos">.</span><span class="pl-en">graphics</span><span class="pl-kos">.</span><span class="pl-en">drawable</span><span class="pl-kos">.</span><span class="pl-v">BitmapDrawable</span><span class="pl-c1">@ad5185c</span>
                                                                             <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">Registry</span><span class="pl-kos">.</span><span class="pl-en">getModelLoaders</span><span class="pl-kos">(</span><span class="pl-v">Registry</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:543</span><span class="pl-kos">)</span>
                                                                             <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">load</span><span class="pl-kos">.</span><span class="pl-en">engine</span><span class="pl-kos">.</span><span class="pl-en">DecodeHelper</span><span class="pl-kos">.</span><span class="pl-en">getLoadData</span><span class="pl-kos">(</span><span class="pl-v">DecodeHelper</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:186</span><span class="pl-kos">)</span>
                                                                             <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">load</span><span class="pl-kos">.</span><span class="pl-en">engine</span><span class="pl-kos">.</span><span class="pl-en">DecodeHelper</span><span class="pl-kos">.</span><span class="pl-en">getCacheKeys</span><span class="pl-kos">(</span><span class="pl-v">DecodeHelper</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:204</span><span class="pl-kos">)</span>
                                                                             <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">load</span><span class="pl-kos">.</span><span class="pl-en">engine</span><span class="pl-kos">.</span><span class="pl-en">DataCacheGenerator</span><span class="pl-kos">.</span>&lt;<span class="pl-en">init</span>&gt;<span class="pl-kos">(</span><span class="pl-v">DataCacheGenerator</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:33</span><span class="pl-kos">)</span>
                                                                             <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">load</span><span class="pl-kos">.</span><span class="pl-en">engine</span><span class="pl-kos">.</span><span class="pl-en">DecodeJob</span><span class="pl-kos">.</span><span class="pl-en">getNextGenerator</span><span class="pl-kos">(</span><span class="pl-v">DecodeJob</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:278</span><span class="pl-kos">)</span>
                                                                             <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">load</span><span class="pl-kos">.</span><span class="pl-en">engine</span><span class="pl-kos">.</span><span class="pl-en">DecodeJob</span><span class="pl-kos">.</span><span class="pl-en">runWrapped</span><span class="pl-kos">(</span><span class="pl-v">DecodeJob</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:259</span><span class="pl-kos">)</span>
                                                                             <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">load</span><span class="pl-kos">.</span><span class="pl-en">engine</span><span class="pl-kos">.</span><span class="pl-en">DecodeJob</span><span class="pl-kos">.</span><span class="pl-en">run</span><span class="pl-kos">(</span><span class="pl-v">DecodeJob</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:230</span><span class="pl-kos">)</span>
                                                                             <span class="pl-en">at</span> <span class="pl-en">java</span><span class="pl-kos">.</span><span class="pl-en">util</span><span class="pl-kos">.</span><span class="pl-en">concurrent</span><span class="pl-kos">.</span><span class="pl-en">ThreadPoolExecutor</span><span class="pl-kos">.</span><span class="pl-en">runWorker</span><span class="pl-kos">(</span><span class="pl-v">ThreadPoolExecutor</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:1133</span><span class="pl-kos">)</span>
                                                                             <span class="pl-en">at</span> <span class="pl-en">java</span><span class="pl-kos">.</span><span class="pl-en">util</span><span class="pl-kos">.</span><span class="pl-en">concurrent</span><span class="pl-kos">.</span><span class="pl-en">ThreadPoolExecutor</span>$Worker<span class="pl-kos">.</span><span class="pl-en">run</span><span class="pl-kos">(</span><span class="pl-v">ThreadPoolExecutor</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:607</span><span class="pl-kos">)</span>
                                                                             <span class="pl-en">at</span> <span class="pl-en">java</span><span class="pl-kos">.</span><span class="pl-en">lang</span><span class="pl-kos">.</span><span class="pl-en">Thread</span><span class="pl-kos">.</span><span class="pl-en">run</span><span class="pl-kos">(</span><span class="pl-v">Thread</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:762</span><span class="pl-kos">)</span>
                                                                             <span class="pl-en">at</span> <span class="pl-en">com</span><span class="pl-kos">.</span><span class="pl-en">bumptech</span><span class="pl-kos">.</span><span class="pl-en">glide</span><span class="pl-kos">.</span><span class="pl-en">load</span><span class="pl-kos">.</span><span class="pl-en">engine</span><span class="pl-kos">.</span><span class="pl-en">executor</span><span class="pl-kos">.</span><span class="pl-en">GlideExecutor</span>$DefaultThreadFactory$1<span class="pl-kos">.</span><span class="pl-en">run</span><span class="pl-kos">(</span><span class="pl-v">GlideExecutor</span><span class="pl-kos">.</span><span class="pl-en">java</span><span class="pl-pds">:386</span><span class="pl-kos">)</span></pre></div>
<h2 dir="auto">Idea</h2>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Glide.with(this).load(bitmap).into(imageView);
Glide.with(this).load(drawable).into(imageView);"><pre class="notranslate"><span class="pl-smi">Glide</span>.<span class="pl-en">with</span>(<span class="pl-smi">this</span>).<span class="pl-en">load</span>(<span class="pl-s1">bitmap</span>).<span class="pl-en">into</span>(<span class="pl-s1">imageView</span>);
<span class="pl-smi">Glide</span>.<span class="pl-en">with</span>(<span class="pl-smi">this</span>).<span class="pl-en">load</span>(<span class="pl-s1">drawable</span>).<span class="pl-en">into</span>(<span class="pl-s1">imageView</span>);</pre></div>
<p dir="auto">This looks weird compared to <code class="notranslate">ImageView.setImageBitmap(bitmap)</code>, but if you need animation and error handling (null bitmap), the above could become an easy to use, fire and forget, go-to line instead of duplicating code.<br>
Note: you've already made a wrapper of <code class="notranslate">ImageView#setImageResource</code> and <code class="notranslate">ImageView#setImageUri</code>.</p>
<p dir="auto">Currently they throw</p>
<blockquote>
<p dir="auto">Caused by: java.lang.IllegalArgumentException: Unknown type android.graphics.Bitmap@44759ab8. You must provide a Model of a type for which there is a registered ModelLoader, if you are using a custom model, you must first call Glide#register with a ModelLoaderFactory for your custom model class.<br>
<code class="notranslate">at com.bumptech.glide.RequestManager.loadGeneric(RequestManager.java:382)</code><br>
<code class="notranslate">at com.bumptech.glide.RequestManager.load(RequestManager.java:374)</code></p>
</blockquote>
<h2 dir="auto">Context</h2>
<p dir="auto">This came up when I was trying to display a captured image using Glide (oversimplified code):</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE), Activity.RESULT_FIRST_USER);

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == REQUEST_CODE_GET_PICTURE &amp;&amp; resultCode == Activity.RESULT_OK) {
        Bitmap bitmap = (Bitmap)data.getExtras().get(&quot;data&quot;);
        Glide.with(this).load(bitmap)/*...*/.into(image);"><pre class="notranslate"><span class="pl-en">startActivityForResult</span>(<span class="pl-k">new</span> <span class="pl-smi">Intent</span>(<span class="pl-smi">MediaStore</span>.<span class="pl-c1">ACTION_IMAGE_CAPTURE</span>), <span class="pl-smi">Activity</span>.<span class="pl-c1">RESULT_FIRST_USER</span>);

<span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-s1">onActivityResult</span>(<span class="pl-smi">int</span> <span class="pl-s1">requestCode</span>, <span class="pl-smi">int</span> <span class="pl-s1">resultCode</span>, <span class="pl-smi">Intent</span> <span class="pl-s1">data</span>) {
    <span class="pl-k">if</span>(<span class="pl-s1">requestCode</span> == <span class="pl-c1">REQUEST_CODE_GET_PICTURE</span> &amp;&amp; <span class="pl-s1">resultCode</span> == <span class="pl-smi">Activity</span>.<span class="pl-c1">RESULT_OK</span>) {
        <span class="pl-smi">Bitmap</span> <span class="pl-s1">bitmap</span> = (<span class="pl-smi">Bitmap</span>)<span class="pl-s1">data</span>.<span class="pl-en">getExtras</span>().<span class="pl-en">get</span>(<span class="pl-s">"data"</span>);
        <span class="pl-smi">Glide</span>.<span class="pl-en">with</span>(<span class="pl-smi">this</span>).<span class="pl-en">load</span>(<span class="pl-s1">bitmap</span>)<span class="pl-c">/*...*/</span>.<span class="pl-en">into</span>(<span class="pl-s1">image</span>);</pre></div>