I'm pretty sure I've had this same problem. I'm willing to bet it has nothing to do with the OS. It's caused by that thing in Android where you can substitute one Drawable
for another depending on your theme or some other condition. It turns out that the Android resource compiler doesn't (always? ever?) check if there's anything 'real' behind an alias.
Here is how you debug it...
Start with this line, it tells you something specific about what is missing--the ID:
Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x1/d=0x7f0d014c a=3 r=0x7f0d014c}
Now go to bin/R.text
, and search for the ID code that is given: 0x7f0d014c
.
There should be something like this:
int attr actionModeCloseDrawable 0x7f0d014c
Now look for the name actionModeCloseDrawable
or whatever it is in your workspace. I believe that you will find that it is an alias for a non-existent resource. i.e., there is a configuration (version number, screen size, etc.) under which that attr does not map to anything at all.
Important things to note:
Make sure to check ALL places where you find actionModeCloseDrawable
or whatever it is. It might look like it is in a place where it 'doesn't matter' but this was a second problem encountered: after I 'fixed' the issue in one abc_myfragment.xml
, I actually had to fix it in abc_myfragment_large.xml
-- Android was automatically calling a different xml file than the one specified in code, based on the device I happened to be running it on.
The top line of your stack trace should help you verify that you are looking in the right place:
android.view.InflateException: Binary XML file line #45: Error inflating class
This tells you that the missing ColorStateList
is being referred to in a section of some XML file somewhere, and that that troublesome section starts on line 45
(i.e., that's where the open angle bracket --"<"-- starting the section is.)
PS What I mean by alias is one of these:
<attr name="abc_my_home_button" format="reference" />
which gets separate further definitions in two separate themes:
<item name="afc_button_home">@drawable/afc_button_home_light</item>
in the file themes_light.xml
and
<item name="afc_button_home">@drawable/afc_button_home_dark</item>
in the file themes_dark.xml
The trouble arises when you leave the final definition out of one of the theme files.
EDIT
Next step: Investigate CustomActionBar
's dependencies. I'm not an expert on styles, so I will assume there are 9 possible places remaining where Android might see a reference to a ColorStateList
that it can't find: in the parent of CustomActionBar
(Widget.Sherlock.Light.ActionBar.Solid.Inverse
), and in each of the 8 items it contains. Comment out those 8 items and get rid of the parent, then rerun your app in the troublesome configuration. Check if the runtime error goes away or, more likely, changes (e.g., line number (and id) changes from #45 to indicate CustomActionBar.Facebook
instead, where many of the same resources are invoked). Then undo the changes one by one until the error changes back to what it was before. This will further localize the problem. After attempting a fix, move slowly, since it is possible that if you do find the problem (e.g., as a non-existent reference) it is replicated in multiple of the 8 items. So uncomment one by one.