Search code examples
androidcrashmaterial-designlaunch

App Crash at Launch (Material Theme issue)


I'm actually creating an app an I would like to use Material Theme Light.

So I put the line android:theme = "@android:style/Theme.Material.light" on the manifest and no errors are displayed.

However when launching the app on my phone it crashes at launch although no errors are displayed in my xml/java sources.

I'm sure this line is the cause, because when I change the manifest to @style/AppTheme, it works and lauches.

It's driving me crazy, I need your help please.


Solution

  • It depends on your activity, What does your activity extend from? If it extends from AppCompatActivity you can't set material theme.

    you should set AppTheme as your theme android:theme="@style/AppTheme"

    and in style file, set AppCompat Theme as your parent:

       <style name="AppTheme" parent="Theme.AppCompat.Light">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>