java.lang.IllegalArgumentException: AppCompat does not support the current theme features
Solution 1
alternative to @sbaar's answer,
keep windowActionBar
to false
and add windowNoTitle
as 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"
Related videos on Youtube
Comments
-
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.
-
Gready about 9 yearsNever seen this but perhaps you're using a feature in R.layout.activity_main that requires a different version of the Android API? - Though Android Studio likes to tell you about those things... Goodluck
-
Charaf Eddine Mechalikh about 9 yearspost your theme.xml or style.xml and the activity_main.xml
-
RaphMclee about 9 yearsCan you put your .gradle files in here as well? You probably depend on a old appcompat?
-
blahdiblah about 9 years
-
-
Adam Varhegyi about 9 yearsAnd why should i modify a thing ? This project was verry well with eclipse for months.
-
SteelBytes about 9 yearsI 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 about 9 yearsBecause 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 about 9 yearsFor me, inheriting the theme from .NoActionBar was the key, no element removal was needed.
-
wilddev about 9 yearsI don't use custom scheme (I use Theme.AppCompat) but I have the same exception. How to fix that?
-
pawegio about 9 yearsthat's strange, but works after switch ActionBarActivity -> AppCompatActivity
-
blueware about 9 yearsThis 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 about 9 yearsHad windowNoTitle and windowActionBar but still didn't work. This fixed it for me. Thanks!
-
dobridog about 9 yearsThis works for themes that don't have an alternative in
NoActionBar
style. In my example it works forTheme.AppCompat.Light.Dialog
-
Anggrayudi H almost 9 years@QadirHussain, No, didn't.
-
Kaveesh Kanwal almost 9 yearsThanks For the answer. :)
-
Setmax almost 9 yearsdont mention it. happy to see your comment.
-
Tariq almost 9 yearsThis works when inheriting from Theme.AppComapt.NoActionBar. Perfect!
-
b4da almost 9 yearsI want to buy you a beer.
-
SteelBytes almost 9 yearsI want to drink that beer :-)
-
Vlado Pandžić about 8 yearsBut how set title now?
-
Hitesh Sahu over 7 yearsAppCompat.NoActionBar made all my textView color white use Theme.AppCompat.Light.NoActionBar instead
-
A Maharaja almost 7 yearsplease help me. i have that problem. why this code not work for me stackoverflow.com/questions/44923662/…
-
Ruchir Baronia almost 7 yearsStill not working? stackoverflow.com/questions/45643107/…
-
Ruchir Baronia almost 7 yearsDoesn't work still stackoverflow.com/questions/45643107/…
-
Ruchir Baronia almost 7 years
-
Neph almost 6 yearsI 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 wassetContentView(R.layout.activity_main);
. Your suggestion fixed it for me (even withparent="Theme.AppCompat.Light.DarkActionBar"
), thanks! -
Lev Khruschev over 3 yearsThank you, it's top 1 answer )