android.support.design.button.MaterialButton throws InflateException

The error may also occur when using any Material Components versions starting from 1.0.0 up to the latest, caused by a theme naming conflict because of themes specified in external libraries, such as Mobile FFmpeg. In this case you need to change the name of your own theme. For further information I explain this in more detail in an answer to this similar question: https://stackoverflow.com/a/57565773/2964379

Basically if you encounter this problem, but know that you are correctly using a MaterialComponents theme, do a search in Android Studio for your app theme using "Find in Path" -> "Scope" -> "All Places". For example, after building and running your app, if your theme name is AppTheme, search for "AppTheme" including the quotes to see if there is a cached XML file that specifies the exact same name.


Apart from adding Theme.MaterialComponents

1)you can also add Theme.MaterialComponents.Bridge if you only want to get atrributes and not default styling

2)Add androidx and com.google.android.material libraries instead of changing the themes.

More info can be found (5) The Components of Material Design (Android Dev Summit '18) - YouTube at 3:25 min


Ensure that the App Theme style is inherited from Theme.MaterialComponents

Example:

<style name="XXXXXAppTheme" parent="@style/Theme.MaterialComponents.Light.DarkActionBar"> 

If you cannot (yet) change the theme for the whole app you can also do it just for this view:

<com.google.android.material.button.MaterialButton
    android:id="@+id/fooButon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="16dp"
    android:fontFamily="sans-serif"
    android:padding="8dp"
==> android:theme="@style/Theme.MaterialComponents.Light"
    app:backgroundTint="@color/base_white" />