119

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.

grebulon
  • 7,697
  • 5
  • 42
  • 66
Adam Varhegyi
  • 11,307
  • 33
  • 124
  • 222
  • Never 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 – Gready Apr 21 '15 at 22:22
  • post your theme.xml or style.xml and the activity_main.xml – Charaf Eddine Mechalikh Apr 21 '15 at 23:20
  • Can you put your .gradle files in here as well? You probably depend on a old appcompat? – RaphMclee Apr 22 '15 at 05:39
  • Possible duplicate of [Upgraded to AppCompat v22.1.0 and now getting IllegalArgumentException: AppCompat does not support the current theme features](http://stackoverflow.com/questions/29790070/upgraded-to-appcompat-v22-1-0-and-now-getting-illegalargumentexception-appcompa) – blahdiblah Apr 30 '15 at 01:14

15 Answers15

242

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>
TheLittleNaruto
  • 8,325
  • 4
  • 54
  • 73
SteelBytes
  • 6,905
  • 1
  • 26
  • 28
  • 4
    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. – SteelBytes Apr 22 '15 at 05:39
  • I don't use custom scheme (I use Theme.AppCompat) but I have the same exception. How to fix that? – wilddev Apr 23 '15 at 09:21
  • 4
    that's strange, but works after switch ActionBarActivity -> AppCompatActivity – pawegio Apr 27 '15 at 18:01
  • 5
    This answer did not work for me. Only @sbaar answer worked. Your theme should inherit from: Theme.AppCompat.NoActionBar in addition to those: false and true – blueware Apr 28 '15 at 07:26
  • 1
    This works for themes that don't have an alternative in ```NoActionBar``` style. In my example it works for ```Theme.AppCompat.Light.Dialog``` – dobridog May 13 '15 at 16:29
  • 1
    This works when inheriting from Theme.AppComapt.NoActionBar. Perfect! – Tariq Jul 30 '15 at 22:17
  • 1
    I want to buy you a beer. – b4da Aug 11 '15 at 03:08
  • I want to drink that beer :-) – SteelBytes Aug 11 '15 at 03:16
  • But how set title now? – Vlado Pandžić Apr 27 '16 at 11:36
  • please help me. i have that problem. why this code not work for me https://stackoverflow.com/questions/44923662/why-appcompat-does-not-support-the-current-theme-features-windowactionbar-false – A Maharaja Jul 05 '17 at 12:05
  • Still not working? https://stackoverflow.com/questions/45643107/appcompat-does-not-support-the-current-theme – Ruchir Baronia Aug 11 '17 at 23:40
  • 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! – Neph Jun 05 '18 at 12:43
  • Thank you, it's top 1 answer ) – Lev Khruschev Nov 29 '20 at 19:00
42

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.

sbaar
  • 1,429
  • 1
  • 17
  • 33
  • 1
    And why should i modify a thing ? This project was verry well with eclipse for months. – Adam Varhegyi Apr 22 '15 at 05:34
  • 3
    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. – jmart Apr 22 '15 at 14:33
  • 3
    For me, inheriting the theme from .NoActionBar was the key, no element removal was needed. – Sergey Aldoukhov Apr 23 '15 at 05:27
33

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.

Anggrayudi H
  • 14,977
  • 11
  • 54
  • 87
16

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

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
wilddev
  • 1,904
  • 2
  • 27
  • 45
  • Had windowNoTitle and windowActionBar but still didn't work. This fixed it for me. Thanks! – avb May 08 '15 at 13:22
5

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

atrivedi
  • 348
  • 1
  • 4
  • 12
3

Make sure that

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

are at the top of everything this works for me....good luck

Gueorgui Obregon
  • 5,077
  • 3
  • 33
  • 57
3

in my case i didnt change to .NoActionBar Theme. i just remove android prefix from this item.

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

and the error goes away.

Setmax
  • 946
  • 6
  • 10
2

if you have added <item name="windowActionBar">false</item>, then ,you need to add

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

to solve the problem.

1

add dependency to gradle like this

compile 'com.android.support:appcompat-v7:21.0.3'
Saurabh Chandra Patel
  • 12,712
  • 6
  • 88
  • 78
1

I solved the issue by my main Activity extending AppCompatActivity :)

joninx
  • 1,775
  • 6
  • 31
  • 59
1

I had same issue somewhat, removed android: from my syles.xml as per below;

 <!-- caused crash -->
 <item name="android:windowActionBar">false</item>
 <item name="android:windowNoTitle">true</item>

 <!-- didn't cause crash -->
 <item name="windowActionBar">false</item>
 <item name="windowNoTitle">true</item>
BENN1TH
  • 2,003
  • 2
  • 31
  • 42
0

I had the same problem when I upgraded the library version from 22.0.0 to 22.1.1 and fixed it by dropping back to the previous version: com.android.support:appcompat-v7:22.0.0 and go back to using ActionBarActivity, not AppCompatActivity in my Activity classes as required by the newer version of the compatibility library. I'll try again later.

Gail
  • 316
  • 2
  • 13
0

just Use this in your style.xml no other editing is needed

 <style name="AppTheme" parent="Theme.AppCompat">

<!-- theme customizations -->

<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

don't add anything in to activity file please leave it

public class Main extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

 }

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} 

@Override
 public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
    return true;
}
return super.onOptionsItemSelected(item);
}

 }
Ribin Haridas
  • 1,630
  • 11
  • 17
0

In Java class change Main extends ActionBarActivity to Main extends Activity. It worked for me.

Qiu
  • 5,651
  • 10
  • 49
  • 56
0

In my case, I look for @rewrihitesh answer, and I notice that I inverted elements order. Changing from

setContentView(R.layout.activity_test);
super.onCreate(savedInstanceState);

to

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);

Fix my problem.

Hope it helps !!

Gueorgui Obregon
  • 5,077
  • 3
  • 33
  • 57