title: Error inflating class android.support.v7.widget.Toolbar
body: <p>I have moved my app from using actionbar to toolbar however end up with the error (full error at bottom). My code:</p>
  
  <p>My Activity:</p>
  
  <pre><code>public class MapsActivity extends ActionBarActivity implements LocationListener {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_maps);
          ...
          mDrawerLayout.setDrawerListener(mDrawerToggle);
  
          toolbar = (Toolbar) findViewById(R.id.toolbar);
  
      if (toolbar != null)
      {
          setSupportActionBar(toolbar);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
          getSupportActionBar().setHomeButtonEnabled(true);
          getSupportActionBar().setElevation(0); // or other
      }
  
          ...
      }
  ...
  }
  </code></pre>
  
  <p>v21/style.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;!-- your app's theme inherits from the Material theme --&gt;
      &lt;style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar"&gt;
          &lt;item name="windowActionBar"&gt;false&lt;/item&gt;
          &lt;item name="android:windowNoTitle"&gt;true&lt;/item&gt;
          &lt;!-- Main theme colors --&gt;
          &lt;!--   your app branding color for the app bar --&gt;
          &lt;item name="android:colorPrimary"&gt;@color/primary&lt;/item&gt;
          &lt;!--   darker variant for the status bar and contextual app bars --&gt;
          &lt;item name="android:colorPrimaryDark"&gt;@color/primary_dark&lt;/item&gt;
          &lt;item name="android:navigationBarColor"&gt;@color/primary&lt;/item&gt;
  
          &lt;!--   theme UI controls like checkboxes and text fields --&gt;
          &lt;item name="android:colorAccent"&gt;@color/accent&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>style.xml</p>
  
  <pre><code>&lt;resources&gt;
  
  &lt;!-- Base application theme. --&gt;
  &lt;style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"&gt;
      &lt;item name="windowActionBar"&gt;false&lt;/item&gt;
      &lt;item name="android:windowNoTitle"&gt;true&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;/resources&gt;
  </code></pre>
  
  <p>gradle dependency</p>
  
  <pre><code>dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile 'com.google.android.gms:play-services:6.5.87'
      compile 'com.android.support:appcompat-v7:21.0.3'
  }
  </code></pre>
  
  <p>my XML layout (after changes made by answer)</p>
  
  <pre><code>LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:ads="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  &gt;
  
  &lt;android.support.v7.widget.Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:minHeight="?attr/actionBarSize"
      android:background="?attr/colorPrimary"
      /&gt;
  
  &lt;android.support.v4.widget.DrawerLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:ads="http://schemas.android.com/apk/res-auto"
  android:id="@+id/drawer_layout"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  &lt;!-- The main content view --&gt;
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;/RelativeLayout&gt;
  
  &lt;!-- The navigation drawer --&gt;
  &lt;RelativeLayout
      android:id="@+id/left_drawer"
      android:layout_width="240dp"
      android:layout_height="match_parent"
      android:layout_gravity="start"
      android:background="#111"&gt;s
  
  
      &lt;/RelativeLayout&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Error below answer gives:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zpwebsites.whatsintown/com.zpwebsites.whatsintown.MapsActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.Toolbar
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
              at android.app.ActivityThread.access$800(ActivityThread.java:144)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.Toolbar
              at android.view.LayoutInflater.createView(LayoutInflater.java:633)
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
              at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
              at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
              at com.zpwebsites.whatsintown.MapsActivity.onCreate(MapsActivity.java:80)
              at android.app.Activity.performCreate(Activity.java:5933)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
              at android.app.ActivityThread.access$800(ActivityThread.java:144)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       Caused by: java.lang.reflect.InvocationTargetException
              at java.lang.reflect.Constructor.newInstance(Native Method)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
              at android.view.LayoutInflater.createView(LayoutInflater.java:607)
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
              at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
              at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
              at com.zpwebsites.whatsintown.MapsActivity.onCreate(MapsActivity.java:80)
              at android.app.Activity.performCreate(Activity.java:5933)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
              at android.app.ActivityThread.access$800(ActivityThread.java:144)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 13
              at android.content.res.TypedArray.getDrawable(TypedArray.java:747)
              at android.view.View.&lt;init&gt;(View.java:3730)
              at android.view.ViewGroup.&lt;init&gt;(ViewGroup.java:491)
              at android.view.ViewGroup.&lt;init&gt;(ViewGroup.java:487)
              at android.support.v7.widget.Toolbar.&lt;init&gt;(Toolbar.java:195)
              at android.support.v7.widget.Toolbar.&lt;init&gt;(Toolbar.java:191)
              at java.lang.reflect.Constructor.newInstance(Native Method)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
              at android.view.LayoutInflater.createView(LayoutInflater.java:607)
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
              at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
              at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
              at com.zpwebsites.whatsintown.MapsActivity.onCreate(MapsActivity.java:80)
              at android.app.Activity.performCreate(Activity.java:5933)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
              at android.app.ActivityThread.access$800(ActivityThread.java:144)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
  </code></pre>