How to use ActionBarActivity with Theme.Material

I created a new project focused on L. preview. However, the starter activity that sdk generates extends ActionBarActivity, however, when I try to run a function generated from scratch, 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 looked around, but Theme.AppCompat.Material does not seem to exist. How to get ActionBarActivity to use new material topics?

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.+' } 
+23
android material-design
Jul 03. '14 at 5:12
source share
3 answers

AppCompat v21. + Theme.AppCompat extends Theme.Base.AppCompat , which extends Theme.Platform.AppCompat , which extends android:Theme.Material on devices with android:Theme.Material (e.g. Android L), so you don't need to do anything to get Material if you are using appcompat.

+53
Jul 03 '14 at 5:45
source share

You need to change the dependency in the gradle assembly to

 compile 'com.android.support:appcompat-v7:21.+' 
+3
Jul 03 '14 at 5:19
source share

Use the following topic:

 android:theme="@style/Base.V7.Theme.AppCompat" > 
-one
Mar 13 '15 at 14:25
source share



All Articles