App crashes on changing theme under styles

6.3k views Asked by At

My Android App :

Target API:22

Min API:15

Device run on :API level 22

I don't understand this whole theme concept ,

In my manifest.xml ,I have set android:theme="@style/AppTheme"

and all activities use this theme

Now my understanding is that they all use the theme called AppTheme which I can now define by extending other themes inside my styles.xml

In my styles.xml

I have this

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

</resources>

My understanding is that AppCompat themes allow us to use newer(say material themes) on older devices also . I run this app on API Level 22 and API Level 15 , it works fine

Now when i change it to

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="android:Theme.Material">
        <!-- Customize your theme here. -->
    </style>

</resources>

It gives a warning saying this theme can be used only on API 21 or above which is correct , now when I ignore the warning and run it in on API 22 it crashes. Why?

Also I tried to make AppTheme's parent as Holo , Light etc ,all of them crash the App , why , please explain?

All of these end up crashing the App

<style name="AppTheme" parent="android:Theme.Translucent">
   <style name="AppTheme" parent="android:Theme.Holo">

Why do these not work , Holo was introduced in 15 right?

I am using 22 ,

and can you please elaborate the difference between Theme....., BaseTheme....,Android..... themeName

And i am running android studio 1.3 and using the latest versions(Stable) of the SDK,SDK build and SDK-Platform tools. Thank you !

3

There are 3 answers

3
Sainath S.R On BEST ANSWER

Sorry , I found the issue , My activity was extending AppCompatActivity instead of the general activity ,I get it now

0
Mohit Khaitan On

When ever working with custom styles you have to take care of the parent you are providing. Try to change the parent theme and it might solve your problem.

1
senithdeelaka On

Try changing the hosting device theme from dark to light or light to dark. I had a similar problem by doing that solved my thing.