5

Zuvor verwendete ich AppCompat mit Version 21.1.2 in meinem Projekt zum Zweck des Materialdesigns mit Symbolleiste umschalten. Aber nach dem Upgrade auf AppCompat v22.1.0 hat meine App seltsam funktioniert. Ich habe sogar einige der Lösungen versucht, wie wie folgtAbrufen von AppCompat unterstützt die aktuelle Designfeature-Ausnahme nach dem Upgrade auf Version AppCompat v22.1.0 Problem

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

Auch Mutter Thema als

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

Aber keine der oben genannten Lösungen Anwendung war für mich nicht hilfreich. Bitte hilf mir mit deinen Tipps und Vorschlägen, mein Problem zu lösen. Ich poste auch meine styles.xml und logcat Fehler für Ihre Referenz. Jede Art von Hilfe wäre hilfreich für mich. Danke im Voraus.

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

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) 

möglich Duplikat java.lang.IllegalArgumentException: AppCompat does not support the current theme features

Antwort

3

.NoActionBar 

von Ihrem Stil entfernen, weil Sie bereits uns e von einem windowNoTitle=false und windowActionBar=false in Ihrem Theme.

+0

Ich habe es richtig überprüfen lassen. – Chandru

6

entfernen .NoActionBar von Ihrem MainActivityTheme

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

Das hat mir geholfen, den Fehler zu lösen. Vielen Dank! – Simon

16

Vielen Dank für Ihre Antworten. Ich löste mein Problem auf eigene Faust durch die Linie

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

Der Fehler trat auf, weil der Zugabe windowNoTitle zweimal zu entfernen als

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

Ich glaube nicht, dass es durch zweimaliges Hinzufügen von windowNoTitle verursacht wird. Wenn du android: windowNoTitle hast, wird es den Absturz verursachen, also musst du den Namen ohne das Android-Präfix verwenden. – starkej2

+0

Ich hatte ein großes Problem, weil ich eine Bibliothek implementieren wollte und ich wusste nicht, warum es abgestürzt war und deine Antwort es behoben hat. Ich brauchte nur die zweite Zeile Ihres Codes. Danke Männer –

+0

Sie sind willkommen @ Alejandroi. Glücklich, dass meine Lösung dir geholfen hat. – Chandru

0

in meinem Fall folgt ich diesen Code haben ==>

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

funktioniert es, wenn ich

löschen
<item name="windowActionBar">false</item> 

hoffe das kann auch helfen !!!

0

Verwenden Sie nur diese in Ihrem style.xml keine andere Bearbeitung benötigt wird

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

etwas hinzufügen, nicht in zu Aktivitätsdatei bitte lassen Sie es

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

vielleicht dies einige Leute helfen

in meinem Fall habe ich nicht verwendet. NoActionBar Theme. Ich entferne nur android Präfix von diesem Artikel.

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

zusätzlich verwende ich android Studio und gradle Schuss für Sie

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

glücklicherweise der Fehler geht weg.

Verwandte Themen