title: Android setting toolbar theme causes app crash
body: <p>I'm trying to change my toolbar theme, but when i do the app crashes.</p>
  
  <p>By seeing other question on SO, it seems i'm doing things right, i also tried to follow some step by step tutorial(<a href="https://guides.codepath.com/android/Using-the-App-Toolbar" rel="nofollow noreferrer">tutorial</a>) but with no success. 
  If no theme is set, the toolbar is shown and the app works. But if a toolbar theme is set, the app crashes with the following stack trace:</p>
  
  <pre><code>Process: com.radiationpressure.mickhardins.mtgrecall.debug, PID: 6840
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.radiationpressure.mickhardins.mtgrecall.debug/com.radiationpressure.mickhardins.mtgrecall.MtgRecallActivity_new}: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
      at android.app.ActivityThread.-wrap12(ActivityThread.java)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:154)
      at android.app.ActivityThread.main(ActivityThread.java:6121)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
   Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference
      at android.content.res.TypedArray.getString(TypedArray.java:202)
      at android.view.View.&lt;init&gt;(View.java:4501)
      at android.widget.TextView.&lt;init&gt;(TextView.java:710)
      at android.widget.TextView.&lt;init&gt;(TextView.java:704)
      at android.support.v7.widget.AppCompatTextView.&lt;init&gt;(AppCompatTextView.java:62)
      at android.support.v7.widget.AppCompatTextView.&lt;init&gt;(AppCompatTextView.java:58)
      at android.support.v7.widget.AppCompatTextView.&lt;init&gt;(AppCompatTextView.java:54)
      at android.support.v7.widget.Toolbar.setTitle(Toolbar.java:756)
      at android.support.v7.widget.ToolbarWidgetWrapper.setTitleInt(ToolbarWidgetWrapper.java:261)
      at android.support.v7.widget.ToolbarWidgetWrapper.setWindowTitle(ToolbarWidgetWrapper.java:243)
      at android.support.v7.app.ToolbarActionBar.&lt;init&gt;(ToolbarActionBar.java:78)
      at android.support.v7.app.AppCompatDelegateImplV9.setSupportActionBar(AppCompatDelegateImplV9.java:223)
      at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:130)
      at com.radiationpressure.mickhardins.mtgrecall.MtgRecallActivity_new.onCreate(MtgRecallActivity_new.java:156)
      at android.app.Activity.performCreate(Activity.java:6682)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727) 
      at android.app.ActivityThread.-wrap12(ActivityThread.java) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:154) 
      at android.app.ActivityThread.main(ActivityThread.java:6121) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
  </code></pre>
  
  <p>  </p>
  
  <p><strong>styles.xml:</strong></p>
  
  <pre><code>&lt;!-- Base application theme. --&gt;
  &lt;style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"&gt;
      &lt;item name="windowActionBar"&gt;false&lt;/item&gt;
      &lt;item name="colorPrimary"&gt;#4CAF50&lt;/item&gt;
      &lt;item name="colorPrimaryDark"&gt;#388E3C&lt;/item&gt;
      &lt;item name="colorAccent"&gt;#448AFF&lt;/item&gt;
      &lt;item name="md_neutral_color"&gt;#4CAF50&lt;/item&gt;
      &lt;item name="preferenceTheme"&gt;@style/PreferenceThemeOverlay.v14.Material&lt;/item&gt;
      &lt;item name="android:windowContentOverlay"&gt;@drawable/bottom_shadow&lt;/item&gt;
  
  &lt;/style&gt;
  
  &lt;style name="AppTheme.Toolbar" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;
      &lt;item name="titleMarginStart"&gt;16dp&lt;/item&gt;
      &lt;item name="android:layout_width"&gt;match_parent&lt;/item&gt;
      &lt;item name="android:layout_height"&gt;?actionBarSize&lt;/item&gt;
      &lt;item name="android:transitionName" tools:ignore="NewApi"&gt;toolbar&lt;/item&gt;
      &lt;item name="android:textColorPrimaryInverse"&gt;@color/md_white_1000&lt;/item&gt;
      &lt;!-- android:textColorPrimary is the color of the title text in the Toolbar  --&gt;
      &lt;item name="android:textColorPrimary"&gt;@color/md_white_1000&lt;/item&gt;
      &lt;!-- actionMenuTextColor is the color of the text of action (menu) items  --&gt;
      &lt;item name="actionMenuTextColor"&gt;@android:color/holo_green_light&lt;/item&gt;
  
  &lt;/style&gt;
  </code></pre>
  
  <p><strong>toolbar.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="?attr/actionBarSize"
      android:background="@color/md_green_500"
      android:theme="@style/AppTheme.Toolbar"
      android:minHeight="@dimen/toolbar_height"
      app:popupTheme="@style/AppTheme.PopupOverlay"/&gt;
  </code></pre>
  
  <p><strong>activity onCreate:</strong></p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState)  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_mtg_recall_new_v2);
      activityPresenter.start()
      toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
      getSupportActionBar().setTitle("title");
      //other code
  }
  </code></pre>
  
  <p>The app is trying to set toolbar title but for some reason it get NPE.
  Any suggestion?
  Thanks in advance </p>
  
  <p><strong>UPDATE 1</strong>
  Updated stack trace after trying the approach suggested by @vikas kumar, unfortunately still experiencing crashes :/</p>