Using Material Button gives ClassNotFound runtime error

In my opinion, the best choice is to create a separate own style to the material button where it extends the material theme:

<style name="MatButton" parent="Theme.MaterialComponents">
    <item name="colorOnPrimary">@android:color/holo_red_light</item>
    <item name="colorPrimary">@android:color/holo_orange_dark</item>
    <item name="colorOnSurface">@android:color/holo_orange_light</item>
</style>

<com.google.android.material.button.MaterialButton
    android:id="@+id/searchBtn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Search"
    android:textColor="@android:color/white"
    android:textAppearance="@style/TextAppearance.MaterialComponents.Button"
    android:theme="@style/MatButton"
    />

if you are using material theme component in your app, then try this.

make changes in your styles.xml from before to after ->

before:

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
</resources>

after:

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
</resources>

As it suggest HERE you have to add a dependency in your build.gradle:

implementation 'com.google.android.material:material:1.0.0-beta01'

Or if you already use google support design library you must change your app theme to inherit from a Material Components theme

<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light">
<!-- ... -->

If you cannot change your theme to inherit from a Material Components theme, you can inherit from a Material Components Bridge theme.

<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light.Bridge">
<!-- ... -->

How Reyske said:

note that it is out of beta now! So you can use implementation 'com.google.android.material:material:1.0.0'