Yesterday I tried to open a one month old honeycomb application and I got errors in my styles.xml file.
Eclipse said:
error: Error retrieving parent for item: No resource found that matches the given name 'android:style/Widget.Holo.Light.ActionBarView_TabView'.
- Trying to build with eclipse
- Trying to build with mvn from the cmd line
- Removing my .m2 repo
- Replacing my android jar with another
- Comparing the mvn -X output with someone's who had it working
Formal explanation:
What is happening is that some styles, like WindowTitle are not public (you won't find them in android.R.style). You should not be extending non public resources. aapt used to let you do that but it was a bug which was fixed in platform-tools r6.
Ok, great I can't extend non public resources, but my style code was copy and pasted from @crafty's blog post: Customizing the Action Bar!
After testing his code I noticed that it also didn't work. Note: There is an issue created for this.
Just for the record, here's how to fix it.
What we need to do is avoid extending the non public resources and copying all the items in our own style.
The two styles that generate the error are:
<style name="MyActionBarTabStyle" parent="android:style/Widget.Holo.Light.ActionBarView_TabView">
<item name="android:background">@drawable/actionbar_tab_bg</item>
<item name="android:paddingLeft">32dp</item>
<item name="android:paddingRight">32dp</item>
</style>
<style name="MyDropDownNav" parent="android:style/Widget.Holo.Light.Spinner.DropDown.ActionBar">
<item name="android:background">@drawable/ad_spinner_background_holo_light</item>
<item name="android:popupBackground">@drawable/ad_menu_dropdown_panel_holo_light</item>
<item name="android:dropDownSelector">@drawable/ad_selectable_background</item>
</style>
Let's fix MyActionBarTabStyle.
To fix it, we will need to copy every non modified items to our style.
We need to open styles.xml at $ANDROID_SDK/platforms/android-11/data/res/values
There we see:
<style name="Widget.Holo.Light.ActionBarView_TabView" parent="Widget.Holo.ActionBarView_TabView">
</style>
No items there, let's now search for: Widget.Holo.ActionBarView_TabView.
<style name="Widget.Holo.ActionBarView_TabView" parent="Widget.ActionBarView_TabView">
<item name="android:background">@drawable/tab_indicator_holo</item>
<item name="android:paddingLeft">16dip</item>
<item name="android:paddingRight">16dip</item>
</style>
There we find three items and we still need to continue up with Widget.ActionBarView_TabView:
<style name="Widget.ActionBarView_TabView">
<item name="android:background">@drawable/minitab_lt</item>
<item name="android:paddingLeft">4dip</item>
<item name="android:paddingRight">4dip</item>
</style>
Great. The same three items and we already have it in our own style. We can get rid of the extension. Leaving our style like this:
<style name="MyActionBarTabStyle">
<item name="android:background">@drawable/actionbar_tab_bg</item>
<item name="android:paddingLeft">32dp</item>
<item name="android:paddingRight">32dp</item>
</style>
The fixed MyDropDownNav ends up extending something non public. It should look like this:
<style name="MyDropDownNav" parent="android:style/Widget.Holo.Light.Spinner">
<item name="android:background">@drawable/ad_spinner_background_holo_light</item>
<item name="android:popupBackground">@drawable/ad_menu_dropdown_panel_holo_light</item>
<item name="android:dropDownSelector">@drawable/ad_selectable_background</item>
</style>
I honestly don't understand what makes an style private or not. They only way I found is checking android.R.style class. If someone knows a better way, please let me know!
Conclusion
Android development has this type of tricks. Fortunately the active community report issues and write about workarounds so everyone can avoid some of the pain :)
Happy coding!