Using Theme.Material.Light.DarkActionBar with Theme.AppCompat.Light.DarkActionBar crashes the application on android L (api v21)

This is what my resources look like

res/values/styles.xml
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="android:windowNoTitle">true</item>
        <item name="windowActionBar">true</item>
    </style>

as he says here

res/values-v21/styles.xml
    <style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
    </style>

and AndroidManifest.xml has

<application android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme" >

in my MainActivity.java I inherit from ActionBarActivity

public class MainActivity extends ActionBarActivity {
....
...
}

Now, when I launch the application on KitKat (API 19), the application starts and I see the Dark Action panel and material design, but when I launch it on Android L (API 21), the application displays a message java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.. I know this happens because I inherit from ActionBarActivity, but if I use the theme appcompatin values-v21/styles.xml, then how would I use the material theme?

+4
1

Theme.AppCompat Material through Platform, Lollipop: res/values-v21/styles.xml .

+6

All Articles