ANDROID: Error inflating class android.support.design.widget.AppBarLayout

@Nilesh answer worked for me but there is more. For those who use androidx;

change these in your layout;

android.support.design.widget.CoordinatorLayout
android.support.design.widget.AppBarLayout
android.support.v7.widget.Toolbar
android.support.design.widget.TabLayout
android.support.v4.view.ViewPager

to this;

androidx.coordinatorlayout.widget.CoordinatorLayout
com.google.android.material.appbar.AppBarLayout
androidx.appcompat.widget.Toolbar
com.google.android.material.tabs.TabLayout
androidx.viewpager.widget.ViewPager

You need to use

<com.google.android.material.appbar.AppBarLayout
<androidx.appcompat.widget.Toolbar

Instead of

<android.support.design.widget.AppBarLayout
<android.support.v7.widget.Toolbar

SAMPLE CODE

<com.google.android.material.appbar.AppBarLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/app_bar"
    android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:elevation="4dp"
        android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >

    </androidx.appcompat.widget.Toolbar>

</com.google.android.material.appbar.AppBarLayout>

Make sure u have added below dependencies

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

UPDATE

if you have used Toolbar and AppBarLayout inside your activity then make sure you have correct imports inside your activity code

import androidx.appcompat.widget.Toolbar
import com.google.android.material.appbar.AppBarLayout