pivotal/robolectric — Issue #159: Background drawable in style causes crash...it is looked up as color
Author: awkay
Created: 2011-11-23 01:17:03+00:00
State: open

I've got a stylized button that sets the background to a drawable via a style:

and is applied as follows:

this works fine in android, but the shadow inflater gets a NPE:

java.lang.RuntimeException: error inflating layout/attendance_stats_by_roster
...
Caused by: java.lang.NullPointerException
at com.xtremelabs.robolectric.res.ColorResourceLoader.getValue(ColorResourceLoader.java:33)
at com.xtremelabs.robolectric.res.ResourceLoader.getColorValue(ResourceLoader.java:341)
at com.xtremelabs.robolectric.shadows.ShadowResources.getColor(ShadowResources.java:66)
at android.content.res.Resources.getColor(Resources.java)
at com.xtremelabs.robolectric.shadows.ShadowView.setBackgroundColor(ShadowView.java:243)
at com.xtremelabs.robolectric.shadows.ShadowButton.applyAttributes(ShadowButton.java:14)
at com.xtremelabs.robolectric.shadows.ShadowView.__constructor__(ShadowView.java:90)
at com.xtremelabs.robolectric.shadows.ShadowView.__constructor__(ShadowView.java:82)

It looks as if the inflator is assuming the background is always a color.