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

JavaAndroidEclipseAndroid Studio

Java Problem Overview


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.

Java Solutions


Solution 1 - Java

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

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

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

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

Solution 5 - Java

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

Solution 6 - Java

Make sure that

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

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

Solution 7 - Java

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.

Solution 8 - Java

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

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

to solve the problem.

Solution 9 - Java

add dependency to gradle like this

compile 'com.android.support:appcompat-v7:21.0.3'

Solution 10 - Java

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

Solution 11 - Java

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>

Solution 12 - Java

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.

Solution 13 - Java

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);
}

 }

Solution 14 - Java

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

Solution 15 - Java

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAdam VarhegyiView Question on Stackoverflow
Solution 1 - JavaSteelBytesView Answer on Stackoverflow
Solution 2 - JavasbaarView Answer on Stackoverflow
Solution 3 - JavaAnggrayudi HView Answer on Stackoverflow
Solution 4 - JavawilddevView Answer on Stackoverflow
Solution 5 - JavaatrivediView Answer on Stackoverflow
Solution 6 - JavarewrihiteshView Answer on Stackoverflow
Solution 7 - JavaSetmaxView Answer on Stackoverflow
Solution 8 - Javauser6088902View Answer on Stackoverflow
Solution 9 - JavaSaurabh Chandra PatelView Answer on Stackoverflow
Solution 10 - JavarussellhoffView Answer on Stackoverflow
Solution 11 - JavaBENN1THView Answer on Stackoverflow
Solution 12 - JavaGailView Answer on Stackoverflow
Solution 13 - JavaRibin HaridasView Answer on Stackoverflow
Solution 14 - Javaشبير البلوشيView Answer on Stackoverflow
Solution 15 - JavaGueorgui ObregonView Answer on Stackoverflow