48

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?

Syex
  • 1,320
  • 1
  • 12
  • 23

7 Answers7

134

Change:

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

to:

<item name="windowNoTitle">true</item>
Ojonugwa Jude Ochalifu
  • 26,627
  • 26
  • 120
  • 132
16

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.

Syex
  • 1,320
  • 1
  • 12
  • 23
  • worked for me — in my case my project was working, then I brought in a custom view and it started crashing like this. Changing the name resolved the issue. I imagine somewhere in the custom view's gradle import there is a definition of "AppTheme" – roberto tomás Apr 26 '16 at 11:37
  • 1
    worked after changing from **parent="AppTheme"** to **parent="Theme.AppCompat.Light.NoActionBar"** – FabioStein Aug 10 '18 at 21:04
1

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>
0

In the theme.xml file, had set

<item name="windowNoTitle">false</item>

to false. changed it to true.

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

do that if you did this.

shekhar g h
  • 1,193
  • 1
  • 9
  • 12
0

I got the same problem and just Rebuilding my project solved the issue. Hope it may help someone.

Akhilendra Singh
  • 661
  • 11
  • 16
0

While migrating to Material3 I faced the same issue. What you need to do is extend the NoActionBar theme.

This:

<style name="Theme.AppDefault" parent="@style/Theme.Material3.DayNight">

Has to be changed to:

<style name="Theme.AppDefault" parent="@style/Theme.Material3.DayNight.NoActionBar">
Andrii Artamonov
  • 622
  • 8
  • 15
-2

Copy this code in your main style:

<style name="Theme.MyTheme" parent="Theme.AppCompat.NoActionBar">

  • why is that such a common answer? looking at the error log, it is explicitly saying the opposite: "windowAcitonBar: false" is _not_ supported. – roberto tomás Apr 25 '16 at 23:45