I created a new project targeting the L preview. The starter activity that the sdk generates extends ActionBarActivity, however, when I try to run the bare-bone generated activity, it throws the following exception:
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:110) at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57) at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:99)
I've looked around but Theme.AppCompat.Material
doesn't seem to exist. How do I make ActionBarActivity to take advantage of the new Material themes?
My build.gradle:
apply plugin: 'com.android.application' android { compileSdkVersion 'android-L' buildToolsVersion '20.0.0' defaultConfig { applicationId 'com.sdchang.example' minSdkVersion 'L' targetSdkVersion 'L' versionCode 1 versionName '1.0' } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } productFlavors { } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.+' compile 'com.mcxiaoke.volley:library:1.0.+@aar' compile 'com.google.code.gson:gson:2.2.+' compile 'com.squareup.okhttp:okhttp:2.0.+' }
AppCompat v21.+'s Theme.AppCompat
extends Theme.Base.AppCompat
which extends Theme.Platform.AppCompat
which extends android:Theme.Material
on 21+ devices (i.e., Android L) devices so you shouldn't have to do anything specific to get the Material
theme if you are using AppCompat.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With