Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android error for `@android:style/Theme.Material.Light`

Hi I am building one android sample application with some material design concepts. I started with https://developer.android.com/training/material/theme.html. I am using eclipse. I have added appcompat_7 support library in library section of my project.Then When I try to apply following theme.

 <style name="AppTheme" parent="@android:style/Theme.Material.Light">

</style>

It gives me following run time error:

11-12 11:32:30.416: E/AndroidRuntime(21375): java.lang.RuntimeException: Unable to start activity
 ComponentInfo{com.example.androidmaterialdesignapi/com.example.androidmaterialdesignapi.MainActivity}: 
 java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

My activity extends ActionBarActivity. Am I doing anything wrong. Need some help. Thank you. Is there any good example to learn material design?

like image 948
nilkash Avatar asked Nov 12 '14 06:11

nilkash


1 Answers

Yes when you use ActionBar activity as parent activity you need to have Theme.AppCompat as your parent style for your customized theme.

Replace your line as follows:

<style name="AppTheme" parent="@style/Theme.AppCompat">

instead of this

<style name="AppTheme" parent="@android:style/Theme.Material.Light">

Hope it helps.

like image 148
virendrao Avatar answered Nov 19 '22 03:11

virendrao