title: ANDROID: Error inflating class android.support.design.widget.AppBarLayout
body: <p>I added a toolbar to my layout and now I get this error when running:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/mainactivity.MainActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #2: Error inflating class android.support.design.widget.AppBarLayout
  </code></pre>
  
  <p>This is my activity layout:</p>
  
  <pre><code>&lt;androidx.constraintlayout.widget.ConstraintLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;include layout="@layout/appbar"/&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  
  <p>and this is my appbar layout:</p>
  
  <pre><code>&lt;android.support.design.widget.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"&gt;
  
      &lt;android.support.v7.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" &gt;
  
      &lt;/android.support.v7.widget.Toolbar&gt;
  
  &lt;/android.support.design.widget.AppBarLayout&gt;
  </code></pre>
  
  <p>In my activity onCreate():</p>
  
  <pre><code>Toolbar toolbar = findViewById(R.id.toolbar);
          if (toolbar != null) {
              setSupportActionBar(toolbar);
              toolbar.setTitle(getTitle());
          }
  </code></pre>
  
  <p>I can't figure out why. Any suggestions?</p>