title: NullPointerException when calling onClickListener
body: <p>I'm making a login system, and I don't know why this happens.
  How can I fix this problem?
  Here's a part of classes regarding NullPointerException.</p>
  
  <pre><code>    final TextView registerButton = (TextView)findViewById(R.id.registerButton);
      registerButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Intent registerIntent=new Intent(LoginActivity.this, RegisterActivity.class);
              LoginActivity.this.startActivity(registerIntent);
          }
      });
  </code></pre>
  
  <p>And the following is a context from logcat.</p>
  
  <pre><code>03-22 10:37:13.066 8500-8500/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm/data@app@com.example.gibong.capstone-1@split_lib_dependencies_apk.apk@classes.dex: Permission denied
  03-22 10:37:13.141 3897-3897/? E/SDAgentPackageStateReceiver: Not going to handle 'com.example.gibong.capstone'!
  03-22 10:37:13.166 6707-6707/? E/Launcher.Model: onPackageAdded :com.example.gibong.capstone
  03-22 10:37:13.296 8526-8526/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm/data@app@com.example.gibong.capstone-1@split_lib_slice_0_apk.apk@classes.dex: Permission denied
  03-22 10:37:13.341 8533-8533/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm/data@app@com.example.gibong.capstone-1@split_lib_slice_1_apk.apk@classes.dex: Permission denied
  03-22 10:37:13.391 8539-8539/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm/data@app@com.example.gibong.capstone-1@split_lib_slice_2_apk.apk@classes.dex: Permission denied
  03-22 10:37:13.461 8543-8543/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm/data@app@com.example.gibong.capstone-1@split_lib_slice_3_apk.apk@classes.dex: Permission denied
  03-22 10:37:13.516 8561-8561/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm/data@app@com.example.gibong.capstone-1@split_lib_slice_4_apk.apk@classes.dex: Permission denied
  03-22 10:37:13.566 8567-8567/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm/data@app@com.example.gibong.capstone-1@split_lib_slice_5_apk.apk@classes.dex: Permission denied
  03-22 10:37:13.616 8572-8572/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm/data@app@com.example.gibong.capstone-1@split_lib_slice_6_apk.apk@classes.dex: Permission denied
  03-22 10:37:13.666 8577-8577/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm/data@app@com.example.gibong.capstone-1@split_lib_slice_7_apk.apk@classes.dex: Permission denied
  03-22 10:37:13.716 8581-8581/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm/data@app@com.example.gibong.capstone-1@split_lib_slice_8_apk.apk@classes.dex: Permission denied
  03-22 10:37:13.771 8587-8587/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm/data@app@com.example.gibong.capstone-1@split_lib_slice_9_apk.apk@classes.dex: Permission denied
  03-22 10:37:14.511 8474-8474/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.example.gibong.capstone, PID: 8474
                                                   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gibong.capstone/com.example.gibong.capstone.LoginActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
                                                       at android.app.ActivityThread.access$1100(ActivityThread.java:221)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:158)
                                                       at android.app.ActivityThread.main(ActivityThread.java:7225)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
                                                       at com.example.gibong.capstone.LoginActivity.onCreate(LoginActivity.java:35)
                                                       at android.app.Activity.performCreate(Activity.java:6876)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
                                                       at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
                                                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                       at android.os.Looper.loop(Looper.java:158) 
                                                       at android.app.ActivityThread.main(ActivityThread.java:7225) 
                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
  </code></pre>
  
  <p>Since I'm not fluent in English and this website, I apologize for my poor use of English and text style.</p>