title: My application crashes when I use OnClicklistener for button even when it is empty
body: <p>My activity is this one, this is LogInActivity which uses layout with same name, when I add the action listeners for the buttons , the application crashes
  please help me out this is happening from last two days</p>
  
  <pre><code>import android.content.Intent;
  import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.Button;
  import android.widget.Toast;
  import android.view.View.OnClickListener;
  
  import java.io.Serializable;
  
  
  public class LogInActivity extends ActionBarActivity {
  
      private Button signUpButton;
      private Button logInButton;
      private Intent signUpChoiceIntent;
      private OnClickListener signupListener;
      private HumLogController humLogController;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setIntentAndButton();
          setContentView(R.layout.activity_log_in);
     }
  
      private void setIntentAndButton(){
          signUpChoiceIntent = new Intent (this , SignUpChoiceActivity.class);
          signUpButton = (Button) findViewById(R.id.firstSignupButton);
          logInButton = (Button) findViewById(R.id.firstLoginButton);
          signupListener = new OnClickListener() {
              @Override
              public void onClick(View v) {
  
              }
          };
          signUpButton.setOnClickListener(signupListener);
      }
  
  }
  </code></pre>
  
  <p>Layout file, two button are creating all the problem:</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" android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:paddingBottom="@dimen/activity_vertical_margin"
      tools:context=".LogInActivity"
      android:background="#ff0aff62"
      android:id="@+id/logInRelativeLayout"&gt;
  
  
      &lt;EditText
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/logInUsernameField"
          android:layout_alignParentTop="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_marginTop="126dp"
          android:textSize="30sp"
          android:background="#ffffffff"
          android:hint="@string/username_field_hint_text"
          android:lines="1"
          android:singleLine="true"
          android:maxLength="40" /&gt;
  
      &lt;EditText
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:inputType="textPassword"
          android:id="@+id/logInPasswordField"
          android:hint="@string/password_field_hint_text"
          android:textSize="30sp"
          android:background="#ffffffff"
          android:layout_centerVertical="true"
          android:layout_alignParentRight="true"
          android:layout_alignParentEnd="true"
          android:layout_alignParentTop="true"
          android:layout_marginTop="176dp"
          android:lines="1"
          android:singleLine="true"
          android:maxLength="15" /&gt;
  
      &lt;Button
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="@string/sign_in_button_text"
          android:id="@+id/firstLoginButton"
          android:layout_centerVertical="true"
          android:layout_alignParentRight="true"
          android:layout_alignParentEnd="true"
          android:layout_alignParentTop="true"
          android:layout_marginTop="226dp"
          android:background="#fff54d70"
          android:textSize="30sp"
          android:textColor="#ffffffff" /&gt;
  
      &lt;Button
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="@string/sign_up_button_text"
          android:id="@+id/firstSignupButton"
          android:layout_alignParentTop="true"
          android:layout_alignParentRight="true"
          android:layout_alignParentEnd="true"
          android:layout_marginTop="376dp"
          android:textSize="30sp"
          android:background="#ff0aff62"
          android:textColor="#ff000000"/&gt;
  
      &lt;TextView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="@string/or_text"
          android:id="@+id/textView"
          android:textSize="30sp"
          android:layout_below="@+id/firstLoginButton"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_alignParentTop="true"
          android:layout_marginTop="306dp"
          android:layout_marginLeft="136dp"
          android:layout_marginStart="136dp"/&gt;
  
  //I am not missing the /relative layout closing tag, it is just not here
  </code></pre>
  
  <p>And this is the stack trace:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.praduman.humlog/com.example.praduman.humlog.LogInActivity}: java.lang.NullPointerException
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
          at android.app.ActivityThread.access$600(ActivityThread.java:141)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:137)
          at android.app.ActivityThread.main(ActivityThread.java:5103)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:525)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
          at dalvik.system.NativeStart.main(Native Method)
   Caused by: java.lang.NullPointerException
          at com.example.praduman.humlog.LogInActivity.setIntentAndButton(LogInActivity.java:41)
          at com.example.praduman.humlog.LogInActivity.onCreate(LogInActivity.java:26)
          at android.app.Activity.performCreate(Activity.java:5133)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
          at android.app.ActivityThread.access$600(ActivityThread.java:141)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:137)
          at android.app.ActivityThread.main(ActivityThread.java:5103)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:525)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>