1

我剛剛創建Android項目使用(hamburger) drawer與midSDKlevel設置爲android-8。Android 5.0運行時異常與AppCompat導致:java.lang.IllegalStateException:您需要使用Theme.AppCompat主題

我第一次跑進appcompat-v7:21.0.0': No resource found that matches the given name: attr 'android:actionModeShareDrawable'問題

,然後在運行Android 5.0模擬器我的RuntimeException

產生的原因:java.lang.IllegalStateException:您需要使用Theme.AppCompat主題(或後裔)與此活動。

\app\src\main\res\values-v21\styles.xml

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="AppTheme" parent="android:Theme.Material.Light"> 
    </style> 
</resources> 

Android清單

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name=".MyActivity" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

應該是什麼確切的字符串與程序兼容性材料設計?

+0

檢查主題您的Android清單? – AruLNadhaN 2014-11-24 05:44:25

+0

它有'android:theme =「@ style/AppTheme」' – 2014-11-24 05:59:33

回答

3

有活動和style.You之間的一個問題是使用ActionBarActivity但你必須Theme.Material.Light,你應該嘗試"Theme.AppCompat"在你的風格

+0

哪種風格?寫更多信息請致電 – 2014-11-24 16:58:20

+1

我正在使用「Theme.AppCompat.NoActionBar」工具欄,您可以使用它。 – massaimara98 2014-11-25 09:55:04

相關問題