android:actionBarStyle requires API level 11

Jitendra picture Jitendra · Mar 11, 2013 · Viewed 50.4k times · Source

While using the ActionBarSherlock in xml at:

<item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>

I got this error:

android:actionBarStyle requires API level 11 (current min is 8) error

I'm using it for back porting my app with actionbar to 2.2 devices.

How to use them both together:

 <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
 <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>

Answer

InsanityOnABun picture InsanityOnABun · Aug 13, 2013

Another option is to use the tools:targetApi attribute, which requires the tools namespace. This acts in a similar fashion to the @TargetApi annotation you can use in java files.

<resources xmlns:tools="http://schemas.android.com/tools">

<style name="MyThemes.MyTheme">
    <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
    <item name="android:actionBarStyle" tools:targetApi="11">@style/Widget.Styled.ActionBar</item>
</style>

</resources>

Note the xmlns:tools="http://schemas.android.com/tools" in the <resources> tag, as it is required.