Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalArgumentException: This component requires that you specify a valid android:textAppearance attribute

I have a com.google.android.material.button.MaterialButton component in one of my layout file and I get this error when I am using the latest version of the Material Components library (com.google.android.material:material:1.0.0-alpha3):

java.lang.IllegalArgumentException: This component requires that you specify a valid android:textAppearance attribute.

It wasn't present in 1.0.0-alpha1. Is this a bug in the library or should I just specify a textAppearance attribute from now?

like image 360
Roland Szép Avatar asked Jun 12 '18 16:06

Roland Szép


3 Answers

Does your theme extend from Theme.MaterialComponents? More info about how to ensure all the components will work correctly can be found at https://material.io/develop/android/docs/getting-started/

like image 182
Cameron Ketcham Avatar answered Nov 18 '22 06:11

Cameron Ketcham


If you are using any of the MaterialComponent, then your theme must extend from the following theme - Theme.MaterialComponents.Light.DarkActionBar

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
like image 30
sodiqOladeni Avatar answered Nov 18 '22 06:11

sodiqOladeni


If you want to keep using your old styles but only want to extend from 'Theme.MaterialComponents' then you can use 'Bridge'.

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorAccent</item>
        <item name="colorAccent">@color/colorPrimaryDark</item>
</style>
like image 48
9paradox Avatar answered Nov 18 '22 07:11

9paradox