robolectric/robolectric — pull request #1281 by jongerrish (2014-09-23 17:46:31+00:00)
Title: Support custom item states in android selectors.

This was failing because custom namespaced attributes are not correctly resolved, since the Node.getName()
returns the fully qualified name including the namespace which cannot be resolved in Robolectric's ResourceIndex. In this case XmlFileBuilder.getResourceId() returns a resource id == 0. Android's ColorStateList.java:207 inflate() method actually gives up processing ALL attributes if it detects a resId == 0 and results in the following error:-

Caused by: org.xmlpull.v1.XmlPullParserException: XML file /build/work/de60fbcefa06825f87444c8bfabcdc39/google3/runfiles/google3/java/com/google/android/apps/adwords/res/drawable/opportunity_detail_header_text_color.xml line #-1 (sorry, not yet implemented):
tag requires a 'android:color' attribute.
at android.content.res.ColorStateList.inflate(ColorStateList.java:226)

Funnily enough, the naming of the attributes matters. The Xerces parser returns attributes in lexicographical order, so if you name your custom attibute > android (e.g: bandroid) then it doesn't fail since it has change to process android:color ;-)

We actually need to check here if the attribute's namespace is the default namespace and if so then we can just return the local name.

This PR is also related to https://github.com/robolectric/robolectric/pull/1272 which will
replace any res-auto custom namespaces with the default package.

Ideally we need both merged to support one of our projects use cases :-)