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?
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/If you are using any of the MaterialComponent, then your theme must extend from the following theme -
Theme.MaterialComponents.Light.DarkActionBar
if u want to keep using your old styles but only want to extend from 'Theme.MaterialComponents' then you can use 'Bridge'.
Check if your AppTheme inherits from MaterialComponents as specified here.
Remember to check all variants of styles.xml file. This was actually the issue I had.
Got stucked in this error even if my theme extends
Theme.MaterialComponents
. I was creating Chips like this :Chip chip = new Chip(getActivity().getBasecontext(), null, R.attr.CustomChipChoice);
.The solution is to change it to
Chip chip = new Chip(getActivity(), null, R.attr.CustomChipChoice);
.Hope it helps.
I had the same problem, I changed my activity theme but it didnt resolved the issue. The i changed my main app theme from AppCompact to Theme.MaterialComponents