title: Android Firebase : null pointer exception in user registration
body: <p>i am registering users to my app with this code,my app crashes on registration and gives a</p>
  
  <pre><code>"FATAL EXCEPTION: main
  java.lang.NullPointerException
  at com.example.ghost.prochat.MainActivity$1.onComplete(MainActivity.java:134)
  at com.google.android.gms.tasks.zzc$1.run(Unknown Source)
  at android.os.Handler.handleCallback(Handler.java:725)
  at android.os.Handler.dispatchMessage(Handler.java:92)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:5069)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  at dalvik.system.NativeStart.main(Native Method)"
  </code></pre>
  
  <p>My code has no syntax errors in that line, what can I do?</p>
  
  <p>Here the method that register the user with Firebase:</p>
  
  <pre><code>FirebaseAuth.getInstance().createUserWithEmailAndPassword(email, password) .addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;() {
          @Override
          public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
              Logger.getLogger(LoginActivity.class.getName()).log(Level.ALL, "createUserWithEmailAndPassword:onComplete:" + task.isSuccessful());
              registerProgressDlg.dismiss();
              if (!task.isSuccessful()) {
                  Logger.getLogger(MainActivity.class.getName()).log(Level.ALL, "createUserWithEmailAndPassword", task.getException());
                  Utils.showDialog(
                          MainActivity.this,
                          getString(R.string.err_singup));
              }
              else {
                  final ArrayList&lt;String&gt; defaultRoom = new ArrayList&lt;String&gt;();
                  defaultRoom.add("home");
                  // Update the user profile information
                  final FirebaseUser user = task.getResult().getUser();
                  UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
                          .setDisplayName(String.valueOf(displayUsername))
                          .setPhotoUri(Uri.parse("https://example.com/jane-q-user/profile.jpg"))
                          .build();
                  user.updateProfile(profileUpdates).addOnCompleteListener(new OnCompleteListener&lt;Void&gt;() {
                      @Override
                      public void onComplete(@NonNull Task&lt;Void&gt; task) {
                          if (task.isSuccessful()) {
                              Logger.getLogger(MainActivity.class.getName()).log(Level.ALL, "User profile updated.");
                              // Construct the ChatUser
                              UserList.user = new ChatUser(user.getUid(),displayUsername, editTextEmail,true,defaultRoom);
                              // Setup link to users database
                              FirebaseDatabase.getInstance().getReference("users").child(user.getUid()).setValue(UserList.user);
                              startActivity(new Intent(MainActivity.this, UserList.class));
                              finish();
                          }
                      }
                  });
              }
          }
      });
  }
  </code></pre>