title: Button may produce null pointer exception (Android Studio)
body: <p>new to Android Studio, and I thought I was doing okay, but ran into an error last night that I just can't seem to fix despite all my best googling efforts. A button on one of my activities 'may produce java.lang.NullPointerException', except it keeps failing every time it's pushed. It may just be something as simple as ordering a line of code in the wrong place etc, but I'm so new to Android studio I don't really know where I'm going wrong. </p>
  
  <pre><code>   public class searchPage extends AppCompatActivity {
  
      private GoogleApiClient client;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_search_page);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      Button goBackButton = (Button) findViewById(R.id.goBackButton);
  
      goBackButton.setOnClickListener(new View.OnClickListener() {
          @Override
  
          public void onClick(View v) {
  
              startActivity(new Intent(searchPage.this, MainActivity.class));
          }
       });
  </code></pre>
  
  <p>Here's the XML</p>
  
  <pre><code> &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="New Button"
      android:id="@+id/goBackButton"
      android:layout_marginTop="88dp"
      android:layout_below="@+id/spinner4"
      android:layout_centerHorizontal="true"
      /&gt;
  </code></pre>
  
  <p>And the Manifest file </p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.example.onein.mobilefinalapp"&gt;
  
   &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity
          android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@style/AppTheme.NoActionBar"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".searchPage"
          android:label="@string/title_activity_search_page"
          android:theme="@style/AppTheme.NoActionBar" /&gt;
  
      &lt;activity
          android:name=".MoviePage"
          android:label="@string/title_activity_movie_page"
          android:theme="@style/AppTheme.NoActionBar"&gt;&lt;/activity&gt;
  
      &lt;meta-data
          android:name="com.google.android.gms.version"
          android:value="@integer/google_play_services_version" /&gt;
   &lt;/application&gt;
  
   &lt;/manifest&gt;
  </code></pre>
  
  <p>Here's the activity_search_page.xml </p>
  
  <p>
  </p>
  
  <pre><code>&lt;android.support.design.widget.AppBarLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:theme="@style/AppTheme.AppBarOverlay"&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"
          app:popupTheme="@style/AppTheme.PopupOverlay" /&gt;
  
    &lt;/android.support.design.widget.AppBarLayout&gt;
  
   &lt;include layout="@layout/content_search_page" /&gt;
  
   &lt;android.support.design.widget.FloatingActionButton
      android:id="@+id/fab"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="bottom|end"
      android:layout_margin="@dimen/fab_margin"
      android:src="@android:drawable/ic_dialog_email" /&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>If you need any other information, please let me know. </p>
  
  <p>Any help greatly appreciated! Thanks. </p>
  
  <p>EDIT - removed duplicate button, and adding in activity_search_page.xml </p>