java.lang.IllegalArgumentException: AppCompat does not support the current theme features

62,671

Solution 1

alternative to @sbaar's answer,

keep windowActionBar to false and add windowNoTitleas well and set it to true.

ie

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

Solution 2

Remove

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

from your theme, then make sure you are inheriting from a .NoActionBar Theme, then set your toolbar like normal.

Solution 3

Make sure that your theme is child from Theme.AppCompat.NoActionBar, then in styles.xml:

<style name="MyMaterialTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="windowNoTitle">true</item>
        ...
</style>

Btw, it's a new issue for Support Library 22.1.

Solution 4

Check if you call setContentView() after super.onCreate(), and not before. This helped in my case.

Solution 5

Use this parent in Style.xml parent="Theme.AppCompat.Light.NoActionBar"

Share:
62,671

Related videos on Youtube

Adam Varhegyi
Author by

Adam Varhegyi

I like the color blue. Often eating gyros.

Updated on December 19, 2020

Comments

  • Adam Varhegyi
    Adam Varhegyi over 3 years

    I tried to migrate a project from Eclipse to Android studio. Finally I am able to run it, but at a certain point I got this exception, and I found nothing in google about this:

    04-22 00:08:15.484    9891-9891/hu.illion.kwindoo E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{hu.illion.kwindoo/hu.illion.kwindoo.activity.MainActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2092)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
        ...    
    Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
        at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:360)
        at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
        at hu.illion.kwindoo.activity.MainActivity.onCreate(MainActivity.java:73)
        at android.app.Activity.performCreate(Activity.java:5047)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
        ...
    

    73. line of MainActivity is:

    setContentView(R.layout.activity_main);
    

    Please advice me if you can.

  • Adam Varhegyi
    Adam Varhegyi about 9 years
    And why should i modify a thing ? This project was verry well with eclipse for months.
  • SteelBytes
    SteelBytes about 9 years
    I had to do this to my app after updating to the latest appcompt (22.1) today. that's all I have changed and my app now works again.
  • jmart
    jmart about 9 years
    Because some hours ago Google released their version 22.1 of the support library, causing this issue in your project (and in mine as well). It's just a coincidence, not because of the migration to Android Studio.
  • Sergey Aldoukhov
    Sergey Aldoukhov about 9 years
    For me, inheriting the theme from .NoActionBar was the key, no element removal was needed.
  • wilddev
    wilddev about 9 years
    I don't use custom scheme (I use Theme.AppCompat) but I have the same exception. How to fix that?
  • pawegio
    pawegio about 9 years
    that's strange, but works after switch ActionBarActivity -> AppCompatActivity
  • blueware
    blueware about 9 years
    This answer did not work for me. Only @sbaar answer worked. Your theme should inherit from: Theme.AppCompat.NoActionBar in addition to those: <item name="windowActionBar">false</item> and <item name="windowNoTitle">true</item>
  • avb
    avb about 9 years
    Had windowNoTitle and windowActionBar but still didn't work. This fixed it for me. Thanks!
  • dobridog
    dobridog about 9 years
    This works for themes that don't have an alternative in NoActionBar style. In my example it works for Theme.AppCompat.Light.Dialog
  • Anggrayudi H
    Anggrayudi H almost 9 years
    @QadirHussain, No, didn't.
  • Kaveesh Kanwal
    Kaveesh Kanwal almost 9 years
    Thanks For the answer. :)
  • Setmax
    Setmax almost 9 years
    dont mention it. happy to see your comment.
  • Tariq
    Tariq almost 9 years
    This works when inheriting from Theme.AppComapt.NoActionBar. Perfect!
  • b4da
    b4da almost 9 years
    I want to buy you a beer.
  • SteelBytes
    SteelBytes almost 9 years
    I want to drink that beer :-)
  • Vlado Pandžić
    Vlado Pandžić about 8 years
    But how set title now?
  • Hitesh Sahu
    Hitesh Sahu over 7 years
    AppCompat.NoActionBar made all my textView color white use Theme.AppCompat.Light.NoActionBar instead
  • A Maharaja
    A Maharaja almost 7 years
    please help me. i have that problem. why this code not work for me stackoverflow.com/questions/44923662/…
  • Ruchir Baronia
    Ruchir Baronia almost 7 years
  • Ruchir Baronia
    Ruchir Baronia almost 7 years
  • Ruchir Baronia
    Ruchir Baronia almost 7 years
  • Neph
    Neph almost 6 years
    I had a similar problem (com.android.support:appcompat-v7:24.2.1 & compileSdkVersion 24) when I tried to remove the action bar without setting it to fullscreen: AppCompat does not support the current theme features: { windowActionBar: false, windowActionBarOverlay: false, android:windowIsFloating: false, windowActionModeOverlay: false, windowNoTitle: false } and the apparently faulty line in my MainActivity was setContentView(R.layout.activity_main);. Your suggestion fixed it for me (even with parent="Theme.AppCompat.Light.DarkActionBar"), thanks!
  • Lev Khruschev
    Lev Khruschev over 3 years
    Thank you, it's top 1 answer )