title: Android Studio Emulator keeps crashing when I run and press buttons on my layouts?
body: <p>When I run any of the layouts, the launch activity layout should run first by default, ask me to log in, and then take me to the page/layout I am clicking. After I log in or register, the emulator crashes saying "Unfortunately, app_name has stopped working." </p>
  
  <p>This is one of the layouts</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &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"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="com.bignerdranch.android.assignment2.EmailReceiptActivity"&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text=" "
      android:id="@+id/textView3"/&gt;
  
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="27dp"
      android:text="@string/fragment_login_message"
      android:layout_gravity="left|top"
      android:id="@+id/fragment_login_message"/&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/username"
      android:layout_gravity="center_horizontal|top"
      android:layout_alignTop="@+id/fragment_login_message"
      android:layout_toRightOf="@+id/fragment_login_message"
      android:layout_toEndOf="@+id/fragment_login_message"
      android:id="@+id/textView2"/&gt;
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceLarge"
      android:text="Send Receipt To:"
      android:id="@+id/send_receipt_to"
      android:layout_marginTop="40dp"
      android:layout_alignParentTop="true"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"/&gt;
  
  &lt;EditText
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:inputType="textEmailAddress"
      android:ems="10"
      android:id="@+id/email_send_receipt"
      android:layout_below="@+id/send_receipt_to"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:layout_marginTop="47dp"
      android:text="Email Address:"
      android:layout_alignParentRight="true"
      android:layout_alignParentEnd="true"/&gt;
  
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Send"
      android:id="@+id/send_receipt_button"
      android:layout_below="@+id/email_send_receipt"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="35dp"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>This is the Java class for that layout</p>
  
  <pre><code>package com.bignerdranch.android.assignment2;
  
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.Button;
  import android.widget.Toast;
  
  public class EmailReceiptActivity extends AppCompatActivity {
  
  
  Button btn_send;
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.main_options_menu, menu);
      return  true;
  }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      int id = item.getItemId();
      if (id == R.id.logoff_menu_item) {
          super.onOptionsItemSelected(item);
          Toast.makeText(this, "Logging You Off...", Toast.LENGTH_LONG).show();
          startActivity(new Intent(EmailReceiptActivity.this,     LaunchActivity.class));
      }
  
      return true;
  }
  
  @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_email_receipt);
  
      btn_send = (Button)findViewById(R.id.send_receipt_button);
      btn_send.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View v){
              //Use the name of this class, and the name class where you want to     be taken when the button is clicked.
              Intent intent = new Intent(EmailReceiptActivity.this, SuccessActivity.class);
              startActivity(intent);
          }
      });
  
  }
  }
  </code></pre>
  
  <p>The options menu
      </p>
  
  <pre><code>&lt;menu
      xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item
          android:id="@+id/logoff_menu_item"
          android:title="@string/logoff_menu_item"&gt;
  
      &lt;/item&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p>The launch activity layout</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;LinearLayout 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"
  android:gravity="center_horizontal"
  android:orientation="vertical"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="com.bignerdranch.android.assignment2.LaunchActivity"&gt;
  
  
  &lt;!-- Login progress --&gt;
  &lt;ProgressBar
      android:id="@+id/login_progress"
      style="?android:attr/progressBarStyleLarge"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginBottom="8dp"
      android:visibility="gone"/&gt;
  
  &lt;ScrollView
      android:id="@+id/login_form"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;LinearLayout
          android:id="@+id/email_login_form"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"&gt;
  
          &lt;android.support.design.widget.TextInputLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
          &lt;AutoCompleteTextView
              android:id="@+id/email"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:hint="@string/prompt_email"
              android:inputType="textEmailAddress"
              android:maxLines="1"
              android:singleLine="true"/&gt;
  
          &lt;/android.support.design.widget.TextInputLayout&gt;
  
          &lt;android.support.design.widget.TextInputLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
          &lt;EditText
              android:id="@+id/password"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:hint="@string/prompt_password"
              android:imeActionId="@+id/login"
              android:imeActionLabel="@string/action_sign_in_short"
              android:imeOptions="actionUnspecified"
              android:inputType="textPassword"
              android:maxLines="1"
              android:singleLine="true"/&gt;
  
          &lt;/android.support.design.widget.TextInputLayout&gt;
  
          &lt;Button
              android:id="@+id/email_sign_in_button"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginTop="16dp"
              android:text="Sign In"
              android:textStyle="bold"/&gt;
  
          &lt;Button
              android:id="@+id/email_register_button"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="Register"
  
              android:textStyle="bold"/&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And the LogCat error:</p>
  
  <pre><code>09-12 07:23:57.680 21430-21430/com.bignerdranch.android.assignment2 E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                        Process: com.bignerdranch.android.assignment2, PID: 21430
                                                                                        java.lang.NullPointerException: Attempt to invoke interface method 'android.view.MenuItem android.view.MenuItem.setIntent(android.content.Intent)' on a null object reference
                                                                                            at com.bignerdranch.android.assignment2.UserAccountActivity.onCreateOptionsMenu(UserAccountActivity.java:22)
                                                                                            at android.app.Activity.onCreatePanelMenu(Activity.java:2823)
                                                                                            at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:340)
                                                                                            at android.support.v7.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:85)
                                                                                            at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.onCreatePanelMenu(AppCompatDelegateImplBase.java:258)
                                                                                            at android.support.v7.app.AppCompatDelegateImplV7.preparePanel(AppCompatDelegateImplV7.java:1320)
                                                                                            at android.support.v7.app.AppCompatDelegateImplV7.doInvalidatePanelMenu(AppCompatDelegateImplV7.java:1600)
                                                                                            at android.support.v7.app.AppCompatDelegateImplV7.access$100(AppCompatDelegateImplV7.java:92)
                                                                                            at android.support.v7.app.AppCompatDelegateImplV7$1.run(AppCompatDelegateImplV7.java:131)
                                                                                            at android.os.Handler.handleCallback(Handler.java:739)
                                                                                            at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                            at android.os.Looper.loop(Looper.java:135)
                                                                                            at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                                            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:903)
                                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
  09-12 07:24:15.778 21645-21645/com.bignerdranch.android.assignment2 E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                        Process: com.bignerdranch.android.assignment2, PID: 21645
                                                                                        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bignerdranch.android.assignment2/com.bignerdranch.android.assignment2.NewSessionActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
                                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
                                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
                                                                                            at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
                                                                                            at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                            at android.os.Looper.loop(Looper.java:135)
                                                                                            at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                                            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:903)
                                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                                                                                         Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
                                                                                            at com.bignerdranch.android.assignment2.NewSessionActivity.onCreate(NewSessionActivity.java:40)
                                                                                            at android.app.Activity.performCreate(Activity.java:5990)
                                                                                            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
                                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
                                                                                            at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
                                                                                            at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                            at android.os.Looper.loop(Looper.java:135) 
                                                                                            at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                                                            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:903) 
                                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
  09-12 07:30:02.938 24027-24027/com.bignerdranch.android.assignment2 E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                        Process: com.bignerdranch.android.assignment2, PID: 24027
                                                                                        java.lang.NullPointerException: Attempt to invoke interface method 'android.view.MenuItem android.view.MenuItem.setIntent(android.content.Intent)' on a null object reference
                                                                                            at com.bignerdranch.android.assignment2.UserAccountActivity.onCreateOptionsMenu(UserAccountActivity.java:22)
                                                                                            at android.app.Activity.onCreatePanelMenu(Activity.java:2823)
                                                                                            at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:340)
                                                                                            at android.support.v7.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:85)
                                                                                            at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.onCreatePanelMenu(AppCompatDelegateImplBase.java:258)
                                                                                            at android.support.v7.app.AppCompatDelegateImplV7.preparePanel(AppCompatDelegateImplV7.java:1320)
                                                                                            at android.support.v7.app.AppCompatDelegateImplV7.doInvalidatePanelMenu(AppCompatDelegateImplV7.java:1600)
                                                                                            at android.support.v7.app.AppCompatDelegateImplV7.access$100(AppCompatDelegateImplV7.java:92)
                                                                                            at android.support.v7.app.AppCompatDelegateImplV7$1.run(AppCompatDelegateImplV7.java:131)
                                                                                            at android.os.Handler.handleCallback(Handler.java:739)
                                                                                            at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                            at android.os.Looper.loop(Looper.java:135)
                                                                                            at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                                            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:903)
                                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
  </code></pre>