<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="java.lang.NullPointerException
1at android.graphics.Rect.&lt;init&gt;(Rect.java:72)
2at android.graphics.drawable.ShapeDrawable.mutate(ShapeDrawable.java:377)
3at android.widget.ImageView.applyColorMod(ImageView.java:1033)
4at android.widget.ImageView.updateDrawable(ImageView.java:611)
5at android.widget.ImageView.setImageDrawable(ImageView.java:359)
6at com.bumptech.glide.request.target.ImageViewTarget.void onLoadCleared(android.graphics.drawable.Drawable)(SourceFile:70)
7at com.bumptech.glide.request.GenericRequest.void clear()(SourceFile:312)
8at com.bumptech.glide.GenericRequestBuilder.com.bumptech.glide.request.target.Target into(com.bumptech.glide.request.target.Target)(SourceFile:603)
9at com.bumptech.glide.GenericRequestBuilder.com.bumptech.glide.request.target.Target into(android.widget.ImageView)(SourceFile:647)
10at com.bumptech.glide.BitmapRequestBuilder.com.bumptech.glide.request.target.Target into(android.widget.ImageView)(SourceFile:486)
11at com.app.Utils void loadImage(android.content.Context,ImageView,java.lang.String,size,drawable)(SourceFile:657)"><pre class="notranslate"><code class="notranslate">java.lang.NullPointerException
1at android.graphics.Rect.&lt;init&gt;(Rect.java:72)
2at android.graphics.drawable.ShapeDrawable.mutate(ShapeDrawable.java:377)
3at android.widget.ImageView.applyColorMod(ImageView.java:1033)
4at android.widget.ImageView.updateDrawable(ImageView.java:611)
5at android.widget.ImageView.setImageDrawable(ImageView.java:359)
6at com.bumptech.glide.request.target.ImageViewTarget.void onLoadCleared(android.graphics.drawable.Drawable)(SourceFile:70)
7at com.bumptech.glide.request.GenericRequest.void clear()(SourceFile:312)
8at com.bumptech.glide.GenericRequestBuilder.com.bumptech.glide.request.target.Target into(com.bumptech.glide.request.target.Target)(SourceFile:603)
9at com.bumptech.glide.GenericRequestBuilder.com.bumptech.glide.request.target.Target into(android.widget.ImageView)(SourceFile:647)
10at com.bumptech.glide.BitmapRequestBuilder.com.bumptech.glide.request.target.Target into(android.widget.ImageView)(SourceFile:486)
11at com.app.Utils void loadImage(android.content.Context,ImageView,java.lang.String,size,drawable)(SourceFile:657)
</code></pre></div>
<p dir="auto">happening sometimes</p>
<p dir="auto">If an ImageView has something that has its (internal) <code class="notranslate">mColorMod</code> field set to true (i.e. there is an alpha or color filter set - see <code class="notranslate">ImageView.applyColorMod()</code>), then when Glide updates the image view providing the <code class="notranslate">TransitionDrawable</code> (the current drawable + <code class="notranslate">SquaringDrawable</code>), the image view attempts to mutate it and crashes (NPE) when calling <code class="notranslate">SquaringDrawable.getConstantState()</code>.</p>
<p dir="auto">Trace from Genymotion v4.4.2</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    java.lang.NullPointerException
            at android.graphics.drawable.LayerDrawable$LayerState.&lt;init&gt;(LayerDrawable.java:671)
            at android.graphics.drawable.TransitionDrawable$TransitionState.&lt;init&gt;(TransitionDrawable.java:249)
            at android.graphics.drawable.TransitionDrawable.createConstantState(TransitionDrawable.java:101)
            at android.graphics.drawable.LayerDrawable.mutate(LayerDrawable.java:608)
            at android.widget.ImageView.applyColorMod(ImageView.java:1216)
            at android.widget.ImageView.updateDrawable(ImageView.java:716)
            at android.widget.ImageView.setImageDrawable(ImageView.java:421)
            at com.bumptech.glide.request.target.ImageViewTarget.setDrawable(ImageViewTarget.java:37)
            at com.bumptech.glide.request.animation.DrawableCrossFadeViewAnimation.animate(DrawableCrossFadeViewAnimation.java:49)
            at com.bumptech.glide.request.animation.DrawableCrossFadeViewAnimation.animate(DrawableCrossFadeViewAnimation.java:14)
            at com.bumptech.glide.request.target.ImageViewTarget.onResourceReady(ImageViewTarget.java:75)
            at com.bumptech.glide.request.target.GlideDrawableImageViewTarget.onResourceReady(GlideDrawableImageViewTarget.java:66)
            at com.bumptech.glide.request.target.GlideDrawableImageViewTarget.onResourceReady(GlideDrawableImageViewTarget.java:12)
            at com.bumptech.glide.request.GenericRequest.onResourceReady(GenericRequest.java:499)
            at com.bumptech.glide.request.GenericRequest.onResourceReady(GenericRequest.java:486)
            at com.bumptech.glide.load.engine.EngineJob.handleResultOnMainThread(EngineJob.java:158)
            at com.bumptech.glide.load.engine.EngineJob.access$100(EngineJob.java:22)
            at com.bumptech.glide.load.engine.EngineJob$MainThreadCallback.handleMessage(EngineJob.java:202)
            at android.os.Handler.dispatchMessage(Handler.java:98)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)"><pre class="notranslate">    <span class="pl-smi">java</span>.<span class="pl-smi">lang</span>.<span class="pl-smi">NullPointerException</span>
            <span class="pl-s1">at</span> <span class="pl-s1">android</span>.<span class="pl-s1">graphics</span>.<span class="pl-s1">drawable</span>.<span class="pl-s1">LayerDrawable$LayerState</span>.&lt;<span class="pl-smi">init</span>&gt;(<span class="pl-smi">LayerDrawable</span>.<span class="pl-smi">java</span>:<span class="pl-c1">671</span>)
            <span class="pl-smi">at</span> <span class="pl-s1">android</span>.<span class="pl-s1">graphics</span>.<span class="pl-s1">drawable</span>.<span class="pl-s1">TransitionDrawable$TransitionState</span>.&lt;<span class="pl-smi">init</span>&gt;(<span class="pl-smi">TransitionDrawable</span>.<span class="pl-smi">java</span>:<span class="pl-c1">249</span>)
            <span class="pl-smi">at</span> <span class="pl-s1">android</span>.<span class="pl-s1">graphics</span>.<span class="pl-s1">drawable</span>.<span class="pl-s1">TransitionDrawable</span>.<span class="pl-en">createConstantState</span>(<span class="pl-smi">TransitionDrawable</span>.<span class="pl-smi">java</span>:<span class="pl-c1">101</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">android</span>.<span class="pl-s1">graphics</span>.<span class="pl-s1">drawable</span>.<span class="pl-s1">LayerDrawable</span>.<span class="pl-en">mutate</span>(<span class="pl-smi">LayerDrawable</span>.<span class="pl-smi">java</span>:<span class="pl-c1">608</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">android</span>.<span class="pl-s1">widget</span>.<span class="pl-s1">ImageView</span>.<span class="pl-en">applyColorMod</span>(<span class="pl-smi">ImageView</span>.<span class="pl-smi">java</span>:<span class="pl-c1">1216</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">android</span>.<span class="pl-s1">widget</span>.<span class="pl-s1">ImageView</span>.<span class="pl-en">updateDrawable</span>(<span class="pl-smi">ImageView</span>.<span class="pl-smi">java</span>:<span class="pl-c1">716</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">android</span>.<span class="pl-s1">widget</span>.<span class="pl-s1">ImageView</span>.<span class="pl-en">setImageDrawable</span>(<span class="pl-smi">ImageView</span>.<span class="pl-smi">java</span>:<span class="pl-c1">421</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">bumptech</span>.<span class="pl-s1">glide</span>.<span class="pl-s1">request</span>.<span class="pl-s1">target</span>.<span class="pl-s1">ImageViewTarget</span>.<span class="pl-en">setDrawable</span>(<span class="pl-smi">ImageViewTarget</span>.<span class="pl-smi">java</span>:<span class="pl-c1">37</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">bumptech</span>.<span class="pl-s1">glide</span>.<span class="pl-s1">request</span>.<span class="pl-s1">animation</span>.<span class="pl-s1">DrawableCrossFadeViewAnimation</span>.<span class="pl-en">animate</span>(<span class="pl-smi">DrawableCrossFadeViewAnimation</span>.<span class="pl-smi">java</span>:<span class="pl-c1">49</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">bumptech</span>.<span class="pl-s1">glide</span>.<span class="pl-s1">request</span>.<span class="pl-s1">animation</span>.<span class="pl-s1">DrawableCrossFadeViewAnimation</span>.<span class="pl-en">animate</span>(<span class="pl-smi">DrawableCrossFadeViewAnimation</span>.<span class="pl-smi">java</span>:<span class="pl-c1">14</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">bumptech</span>.<span class="pl-s1">glide</span>.<span class="pl-s1">request</span>.<span class="pl-s1">target</span>.<span class="pl-s1">ImageViewTarget</span>.<span class="pl-en">onResourceReady</span>(<span class="pl-smi">ImageViewTarget</span>.<span class="pl-smi">java</span>:<span class="pl-c1">75</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">bumptech</span>.<span class="pl-s1">glide</span>.<span class="pl-s1">request</span>.<span class="pl-s1">target</span>.<span class="pl-s1">GlideDrawableImageViewTarget</span>.<span class="pl-en">onResourceReady</span>(<span class="pl-smi">GlideDrawableImageViewTarget</span>.<span class="pl-smi">java</span>:<span class="pl-c1">66</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">bumptech</span>.<span class="pl-s1">glide</span>.<span class="pl-s1">request</span>.<span class="pl-s1">target</span>.<span class="pl-s1">GlideDrawableImageViewTarget</span>.<span class="pl-en">onResourceReady</span>(<span class="pl-smi">GlideDrawableImageViewTarget</span>.<span class="pl-smi">java</span>:<span class="pl-c1">12</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">bumptech</span>.<span class="pl-s1">glide</span>.<span class="pl-s1">request</span>.<span class="pl-s1">GenericRequest</span>.<span class="pl-en">onResourceReady</span>(<span class="pl-smi">GenericRequest</span>.<span class="pl-smi">java</span>:<span class="pl-c1">499</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">bumptech</span>.<span class="pl-s1">glide</span>.<span class="pl-s1">request</span>.<span class="pl-s1">GenericRequest</span>.<span class="pl-en">onResourceReady</span>(<span class="pl-smi">GenericRequest</span>.<span class="pl-smi">java</span>:<span class="pl-c1">486</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">bumptech</span>.<span class="pl-s1">glide</span>.<span class="pl-s1">load</span>.<span class="pl-s1">engine</span>.<span class="pl-s1">EngineJob</span>.<span class="pl-en">handleResultOnMainThread</span>(<span class="pl-smi">EngineJob</span>.<span class="pl-smi">java</span>:<span class="pl-c1">158</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">bumptech</span>.<span class="pl-s1">glide</span>.<span class="pl-s1">load</span>.<span class="pl-s1">engine</span>.<span class="pl-s1">EngineJob</span>.<span class="pl-en">access$100</span>(<span class="pl-smi">EngineJob</span>.<span class="pl-smi">java</span>:<span class="pl-c1">22</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">bumptech</span>.<span class="pl-s1">glide</span>.<span class="pl-s1">load</span>.<span class="pl-s1">engine</span>.<span class="pl-s1">EngineJob$MainThreadCallback</span>.<span class="pl-en">handleMessage</span>(<span class="pl-smi">EngineJob</span>.<span class="pl-smi">java</span>:<span class="pl-c1">202</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">android</span>.<span class="pl-s1">os</span>.<span class="pl-s1">Handler</span>.<span class="pl-en">dispatchMessage</span>(<span class="pl-smi">Handler</span>.<span class="pl-smi">java</span>:<span class="pl-c1">98</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">android</span>.<span class="pl-s1">os</span>.<span class="pl-s1">Looper</span>.<span class="pl-en">loop</span>(<span class="pl-smi">Looper</span>.<span class="pl-smi">java</span>:<span class="pl-c1">136</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">android</span>.<span class="pl-s1">app</span>.<span class="pl-s1">ActivityThread</span>.<span class="pl-en">main</span>(<span class="pl-smi">ActivityThread</span>.<span class="pl-smi">java</span>:<span class="pl-c1">5017</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">java</span>.<span class="pl-s1">lang</span>.<span class="pl-s1">reflect</span>.<span class="pl-s1">Method</span>.<span class="pl-en">invokeNative</span>(<span class="pl-smi">Native</span> <span class="pl-s1">Method</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">java</span>.<span class="pl-s1">lang</span>.<span class="pl-s1">reflect</span>.<span class="pl-s1">Method</span>.<span class="pl-en">invoke</span>(<span class="pl-smi">Method</span>.<span class="pl-smi">java</span>:<span class="pl-c1">515</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">android</span>.<span class="pl-s1">internal</span>.<span class="pl-s1">os</span>.<span class="pl-s1">ZygoteInit$MethodAndArgsCaller</span>.<span class="pl-en">run</span>(<span class="pl-smi">ZygoteInit</span>.<span class="pl-smi">java</span>:<span class="pl-c1">779</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">com</span>.<span class="pl-s1">android</span>.<span class="pl-s1">internal</span>.<span class="pl-s1">os</span>.<span class="pl-s1">ZygoteInit</span>.<span class="pl-en">main</span>(<span class="pl-smi">ZygoteInit</span>.<span class="pl-smi">java</span>:<span class="pl-c1">595</span>)
            <span class="pl-s1">at</span> <span class="pl-s1">dalvik</span>.<span class="pl-s1">system</span>.<span class="pl-s1">NativeStart</span>.<span class="pl-en">main</span>(<span class="pl-smi">Native</span> <span class="pl-s1">Method</span>)</pre></div>