Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppCompat does not support the current theme features - nothing works

Tags:

android

I'm trying to use MaterialDesign in my project but I'm getting this error all the time:

Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features: { windowActionBar: false, windowActionBarOverlay: false, android:windowIsFloating: false, windowActionModeOverlay: false, windowNoTitle: false }
        at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:371)
        at android.support.v7.app.AppCompatDelegateImplV7.initWindowDecorActionBar(AppCompatDelegateImplV7.java:173)
        at android.support.v7.app.AppCompatDelegateImplBase.getSupportActionBar(AppCompatDelegateImplBase.java:87)
        at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:197)
        at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:99)
        at de.memorian.playpal.MainActivity.afterInject(MainActivity.java:72)

I've reade through similar problems but everytime I'm getting the same error.

MainActivity.java:

@EActivity(R.layout.activity_main)
public class MainActivity extends AppCompatActivity {

@ViewById
protected Toolbar toolbar;

@AfterInject
public void afterInject() {
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
}
}

styles.xml:

<style name="AppTheme" parent="AppTheme.Base"/>

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

styles-v21.xml:

style name="AppTheme" parent="AppTheme.Base">
    <!-- enable window content transitions -->
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <!-- specify shared element transitions -->
    <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>

I've tried setting parent theme to any derivation of .NoActionBar, but still. I've also tried removing all code from AndroidAnnotations and doing it the regular way with setContentView and findViewById(R.id.toolbar). Only thing that bothers me is that I set windowNoTitle to true but in the log it says it is false.

Any help?

like image 274
Syex Avatar asked Sep 16 '15 16:09

Syex


3 Answers

Change:

<item name="android:windowNoTitle">true</item>

to:

<item name="windowNoTitle">true</item>
like image 169
Ojonugwa Jude Ochalifu Avatar answered Nov 04 '22 01:11

Ojonugwa Jude Ochalifu


To anyone else having this problem, I just found the problem: Apparently there exists another theme with name "AppTheme". I don't know why and how, but changing my theme's name solved the problem.

This was the answer to my problem.

like image 43
Syex Avatar answered Nov 04 '22 00:11

Syex


Add them on Activity MainActivity in your AndroidManifest.xml file

like this

        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
like image 1
Saurabh Gaddelpalliwar Avatar answered Nov 04 '22 00:11

Saurabh Gaddelpalliwar