Paul Verest
Paul Verest

Reputation: 63912

Android 5.0 RuntimeException with AppCompat Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme

I just created Android project using (hamburger) drawer with midSDKlevel set to android-8.

I first ran into appcompat-v7:21.0.0': No resource found that matches the given name: attr 'android:actionModeShareDrawable' issue

, then running in Android 5.0 emulator I got RuntimeException

Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

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

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

What exact string should be for Material Design with AppCompat ?

Upvotes: 1

Views: 833

Answers (1)

massaimara98
massaimara98

Reputation: 7449

There is a problem between activity and style.You are using ActionBarActivity but you have Theme.Material.Light ,you should try "Theme.AppCompat" in your style

Upvotes: 3

Related Questions