title: Android: RuntimeException, unable to start activity ComponentInfo, toolbar error
body: <p>I've got this error:</p>
  
  <blockquote>
    <p>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kkk.findyourbook/com.kkk.findyourbook.activities.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.support.v7.widget.Toolbar.findViewById(int)' on a null object reference</p>
    
    <p>Caused by: java.lang.NullPointerException: Attempt to invoke virtual
    method 'android.view.View
    android.support.v7.widget.Toolbar.findViewById(int)' on a null object
    reference</p>
  </blockquote>
  
  <p>This is weird because it happened just now, I mean I used to run my app without any problems.</p>
  
  <p>My <code>onCreate()</code> method looks like this:</p>
  
  <pre><code>@Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      ButterKnife.bind(this);
  
      getNavigationDrawerItems();
  
      setupToolbar();
      setupDrawerToggle();
  
      DrawerItemCustomAdapter adapter = new DrawerItemCustomAdapter(this, R.layout.drawer_item, mNavigationDrawerItems);
      drawerList.setAdapter(adapter);
      drawerList.setOnItemClickListener(new DrawerItemClickListener());
  
      mActionBar = getSupportActionBar();
      mActionBar.setDisplayHomeAsUpEnabled(false);
      mActionBar.setHomeButtonEnabled(true);
      mActionBar.setDisplayShowTitleEnabled(true);
  
      assert drawerLayout != null;
      drawerLayout.addDrawerListener(drawerToggle);
  
      sFragmentManager = getSupportFragmentManager();
  
      // Check that the activity is using the layout version with
      // the fragment_container FrameLayout
      if (findViewById(R.id.container) != null) {
  
          // However, if we're being restored from a previous state,
          // then we don't need to do anything and should return or else
          // we could end up with overlapping fragments.
          if (savedInstanceState != null) {
              return;
          }
  
          // Create a new Fragment to be placed in the activity layout
          Fragment fragment = new SampleFragment();
  
          // In case this activity was started with special instructions from an
          // Intent, pass the Intent's extras to the fragment as arguments
          //            firstFragment.setArguments(getIntent().getExtras());
  
          // Add the fragment to the 'fragment_container' FrameLayout
          sFragmentManager.beginTransaction()
              .add(R.id.container, fragment)
              .commit();
      }
  }
  </code></pre>
  
  <p><code>setupToolbar()</code> method:</p>
  
  <pre><code>void setupToolbar() {
      setSupportActionBar(toolbar);
      getSupportActionBar().setDisplayShowHomeEnabled(true);
  }
  </code></pre>
  
  <p>and in my fragment:</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      View fragment = inflater.inflate(R.layout.fragment_sample, container, false);
      ButterKnife.bind(this, fragment);
  
      toolbarInit();
  
      return fragment;
  }
  
  private void toolbarInit() {
      mToolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);
  
      TextView toolbarTitle = (TextView) mToolbar.findViewById(R.id.toolbarTitle);
      toolbarTitle.setText(getActivity().getResources().getString(R.string.cat_my_books));
  }
  </code></pre>
  
  <p>Can you help me with this error?</p>
  
  <p>EDIT:</p>
  
  <p>toolbar layout:</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:local="http://schemas.android.com/apk/res-auto"
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:minHeight="?attr/actionBarSize"
      android:background="@color/colorPrimary"
      local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
      local:popupTheme="@style/ThemeOverlay.AppCompat.Light" &gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="horizontal"&gt;
          &lt;ImageView
              android:id="@+id/toolbarIconLeft"
              android:layout_width="32dp"
              android:layout_height="32dp"
              android:layout_gravity="end"
              android:padding="4dp"
              android:src="@drawable/logo"
              android:visibility="gone"
              android:contentDescription="toolbarIcon" /&gt;
          &lt;TextView
              android:id="@+id/toolbarTitle"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:layout_gravity="center"
              android:layout_marginRight="8dp"
              android:layout_marginEnd="8dp"
              android:textAlignment="center"
              android:gravity="center_horizontal"
              android:textSize="18sp"
              android:textAllCaps="true"
              android:textColor="@android:color/white"
              android:textStyle="bold" /&gt;
          &lt;ImageView
              android:id="@+id/toolbarIcon"
              android:layout_width="32dp"
              android:layout_height="32dp"
              android:layout_gravity="end"
              android:layout_marginRight="12dp"
              android:layout_marginEnd="12dp"
              android:visibility="invisible"
              android:src="@drawable/logo"
              android:contentDescription="toolbarIcon" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/android.support.v7.widget.Toolbar&gt;
  </code></pre>