Getting AppCompat does not support the current theme thread exception after upgrading to AppCompat v22.1.0

I used to use AppCompat with version 21.1.2 in my project in order to switch material with the toolbar. But after upgrading to AppCompat v22.1.0, my application started working weirdly. I even tried some of the solutions, for example as follows

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

Also applying the parent theme as

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

But none of the above solutions helped me. So kindly, please help me in your advice and suggestions in order to overcome my problem that I am now facing. I also post my styles.xml and logcat errors for your reference. Any help would be helpful to me. Thanks in advance.

styles.xml

  <style name="MainActivityTheme" parent="Theme.AppCompat.NoActionBar"> <item name="colorPrimary">@color/white</item> <item name="colorPrimaryDark">#F2F2F2</item> <item name="android:windowNoTitle">true</item> <item name="windowNoTitle">true</item> <item name="windowActionBar">false</item> <item name="drawerArrowStyle">@style/DrawerArrowStyle</item> <item name="colorControlActivated">@color/yellow</item> </style> 

Logcat Error:

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sample.app/com.sample.app.activities.MainActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) at android.app.ActivityThread.access$900(ActivityThread.java:175) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5602) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(Native Method) 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 com.sample.app.activities.MainActivity.onCreate(MainActivity.java:24) at android.app.Activity.performCreate(Activity.java:5451) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)            at android.app.ActivityThread.access$900(ActivityThread.java:175)            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)            at android.os.Handler.dispatchMessage(Handler.java:102)            at android.os.Looper.loop(Looper.java:146)            at android.app.ActivityThread.main(ActivityThread.java:5602)            at java.lang.reflect.Method.invokeNative(Native Method)            at java.lang.reflect.Method.invoke(Method.java:515)            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)            at dalvik.system.NativeStart.main(Native Method) 

possible duplicate java.lang.IllegalArgumentException: AppCompat does not support current theme functions

+5
source share
6 answers

Thank you all for your answers. I solved my problem myself by deleting the line

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

The error occurred due to adding windowNoTitle two times as follows

 <item name="android:windowNoTitle">true</item> <item name="windowNoTitle">true</item> 
+16
source

Remove .NoActionBar from your MainActivityTheme

 <style name="MainActivityTheme" parent="Theme.AppCompat"> // ................................................ <item name="windowNoTitle">true</item> <item name="windowActionBar">false</item> </style> 
+6
source

Delete

 .NoActionBar 

from your style because you are already using from windowNoTitle=false and windowActionBar=false in your theme.

+3
source

maybe this will help some people

in my case, I did not use .NoActionBar Theme. I just remove the android prefix from this element.

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

Also, I am using android studio and gradle for you -

 'com.android.support:appcompat-v7:22.2.0' 

Fortunately, the error goes away.

+1
source

in my case I have this code ==>

 <style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="android: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> 

it works when i delete

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

hope this helps too !!!

0
source

Just use it in your .xml style. No other editing required

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

do not add anything to the activity file, 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); } } 
0
source

All Articles