title: Getting a NullPointerException with AppCompat
body: <p>I'm trying to implements 'Material design' for pre-5.0 using AppCompat v21, but I'm getting a null pointer exception when i try to put on the new 'toolbar'. I followed this guide to implement it <a href="http://android-developers.blogspot.com.es/2014/10/appcompat-v21-material-design-for-pre.html" rel="nofollow">http://android-developers.blogspot.com.es/2014/10/appcompat-v21-material-design-for-pre.html</a>. But i cant find the error that causes the NPE.</p>
  
  <p>app.gradle</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
  compileSdkVersion 21
  buildToolsVersion "21.1.2"
  
  defaultConfig {
      applicationId "com.example.alejandrohall.myapplication"
      minSdkVersion 14
      targetSdkVersion 21
      versionCode 1
      versionName "1.0"
  }
  buildTypes {
      release {
          minifyEnabled false
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.pro'
      }
  }
  }
  
  dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.android.support:appcompat-v7:21.0.3'
  }
  </code></pre>
  
  <p>toolbar.xml</p>
  
  <pre><code>&lt;android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/my_awesome_toolbar"
      android:layout_height="wrap_content"
      android:layout_width="match_parent"
  
      android:background="?attr/colorPrimary"/&gt;
  </code></pre>
  
  <p>styles.xml</p>
  
  <pre><code>&lt;resources&gt;
  
  &lt;!-- Base application theme. --&gt;
  &lt;style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"&gt;
  
  
  
      &lt;!-- Customize your theme here. --&gt;
  
      &lt;item name="colorPrimary"&gt;@color/material_blue_grey_950&lt;/item&gt;
      &lt;item name="windowActionModeOverlay"&gt;true&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;/resources&gt;
  </code></pre>
  
  <p>activity_mail.xml</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
  android:layout_height="match_parent" tools:context=".MainActivity"&gt;
  
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceLarge"
      android:text="HOLA MUNDO"
      android:id="@+id/textView"
      android:layout_centerVertical="true"
      android:layout_centerHorizontal="true" /&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>MainActivity.java
      package com.example.alejandrohall.myapplication;</p>
  
  <pre><code>import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.support.v7.widget.Toolbar;
  
  
  
  public class MainActivity extends ActionBarActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
          setSupportActionBar(toolbar);
  
      }
  
  
  
  }
  </code></pre>
  
  <p>the error</p>
  
  <pre><code>Process: com.example.alejandrohall.myapplication, PID: 6461
          java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.alejandrohall.myapplication/com.example.alejandrohall.myapplication.MainActivity}: java.lang.NullPointerException
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
          at android.app.ActivityThread.access$800(ActivityThread.java:139)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
          at android.os.Handler.dispatchMessage(Handler.java:102)
          at android.os.Looper.loop(Looper.java:136)
          at android.app.ActivityThread.main(ActivityThread.java:5086)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:515)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
          at dalvik.system.NativeStart.main(Native Method)
          Caused by: java.lang.NullPointerException
          at android.support.v7.internal.widget.ToolbarWidgetWrapper.&lt;init&gt;(ToolbarWidgetWrapper.java:95)
          at android.support.v7.internal.widget.ToolbarWidgetWrapper.&lt;init&gt;(ToolbarWidgetWrapper.java:88)
          at android.support.v7.internal.app.ToolbarActionBar.&lt;init&gt;(ToolbarActionBar.java:84)
          at android.support.v7.app.ActionBarActivityDelegateBase.setSupportActionBar(ActionBarActivityDelegateBase.java:175)
          at android.support.v7.app.ActionBarActivity.setSupportActionBar(ActionBarActivity.java:92)
          at com.example.alejandrohall.myapplication.MainActivity.onCreate(MainActivity.java:17)
          at android.app.Activity.performCreate(Activity.java:5248)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
                      at android.app.ActivityThread.access$800(ActivityThread.java:139)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5086)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                      at dalvik.system.NativeStart.main(Native Method)
  </code></pre>