ShapeDrawable mutation not working on Android 4.1.2
java.lang.NullPointerException
at android.graphics.Rect.<init>(Rect.java:72)
at android.graphics.drawable.ShapeDrawable.mutate(ShapeDrawable.java:377)
at com.facebook.drawee.drawable.ForwardingDrawable.mutate(ForwardingDrawable.java:160)
at com.facebook.drawee.drawable.FadeDrawable.drawDrawableWithAlpha(FadeDrawable.java:304)
at com.facebook.drawee.drawable.FadeDrawable.draw(FadeDrawable.java:293)
at com.facebook.drawee.drawable.ForwardingDrawable.draw(ForwardingDrawable.java:140)
at com.facebook.drawee.generic.GenericDraweeHierarchy$RootDrawable.draw(GenericDraweeHierarchy.java:133)
at android.widget.ImageView.onDraw(ImageView.java:984)
Any ideas what could be causing this? Only seems to be happening specifically on Android version 4.1.2, both on Samsung devices.
There seems to be a bug in 4.1.2: ShapeDrawable.mutate copies its padding Rect without checking whether it is null anywhere. Calling setPadding(new Rect()) before calling mutate should help work around this issue. Marking this as a bug until some work around is in place.
Thank you for the quick response! Is there anything I can do in the meantime to mitigate the issue on my side?
You can try setting padding on the shape drawable in your app. Let me know if that helps.
So why didn't you fix this? Why didn't you accept pull request from emhagman?
I fixed the problem by adding drawable.setPadding(new Rect()) to the drawable, that I used in
GenericDraweeHierarchyBuilder(getResources())
.setFailureImage(drawable);
@Liverm0r, the PR was taken back by @emhagman one hour after he opened it. Let me try to find some time this week to look into it
I am facing same issue for setPlaceholderImage. any workaround?
Closing since we will not be fixing this (due to Android 4.1.2 being quite obsolete at this point)