androidandroid-themeandroid-appcompatmaterial-design

Material Design support below Lollipop - crashes


I've been trying to implement the Material Design theme, following these instructions.

My styles.xml:

<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->

</style>

<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
     <item name="displayOptions">useLogo|showHome</item>
    <item name="logo">@drawable/home_page_logo</item>
    <item name="background">@color/actionbar_background_color</item>
    <item name="textColor">@color/white</item>
    <item name="titleTextStyle">@style/MyActionBarTextStyle</item>
</style>

No matter what I tried, the application crashes the second I launch my main activity on onCreate() with this crash log:

Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
 at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
 at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)

Did anyone experience this issue? any suggestions on what might cause this?

Edit: It's definitely something in my styles.xml theme. If I force the app to use the default Theme.AppCompat theme, it works. What might cause a theme to fail? I verified the ActionBar attributes are not using "android:". Anything else?


Solution

  • SOLVED...

    2 of my jar libs apparently have generated values.xml that contains styles of both AppTheme and AppBaseTheme. I verified only our dependencies modules, as jar libraries shouldn't declare application themes, specially not with the name of the default ones.

    Before posting the answer, I added to my AndroidManifest.xml <application> tools:replace="android:theme" and declared the new theme, assuming it'll work and my application will override any other theme.

    The solution eventually, stupid as it is, was to rename my own AppTheme and AppBaseTheme to different names and now it works. Hours spent on such a trivial fix. Hopefully, this will spare some time for others.