title: My app crashes when I hit log out
body: <p>I have an app that allows me to log in and out. the log out button now seems to crash the app when i press it when it was working ok before. It still logs out the user and when you go back into the app you have to sign in again.</p>
  
  <p>I have added my whole on create method below where the action happens at the bottom. Just incase i have added a duplicate or something that i am missing</p>
  
  <pre><code> //view objects
      private TextView textViewUserEmail;
      private Button buttonLogout;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_profile);
  
          buttonAddProducts = (Button) findViewById(R.id.buttonAddProducts);
          buttonAddBeverages = (Button) findViewById(R.id.buttonAddBeverages);
          buttonLogout = (Button) findViewById(R.id.buttonLogout);
          firebaseAuth = FirebaseAuth.getInstance();
          buttonAddProducts.setVisibility(View.GONE);
          buttonAddBeverages.setVisibility(View.GONE);
  
          databaseUsers = FirebaseDatabase.getInstance().getReference("users");
  
          String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
          DatabaseReference currentUserReference = databaseUsers.child(uid);
          currentUserReference.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot userSnapshot) {
                  if (userSnapshot.exists()) {
                      User user = userSnapshot.getValue(User.class);
  
                      if(user.getAdminUser() == true)
                      {
                          buttonAddProducts.setVisibility(View.VISIBLE);
                          buttonAddBeverages.setVisibility(View.VISIBLE);
                      }
                  }
                  else{
                      Log.i("myInfoTag", "Connection problem");
                  }
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
                  throw databaseError.toException(); // don't ignore exceptions
              }
          });
  
  
          //if the user is not logged in
          //that means current user will return null
          if(firebaseAuth.getCurrentUser() == null){
              //closing this activity
              finish();
              //starting login activity
              startActivity(new Intent(this, LoginActivity.class));
          }
  
          //getting current user
          FirebaseUser user = firebaseAuth.getCurrentUser();
  
          //initializing views
          textViewUserEmail = (TextView) findViewById(R.id.textViewUserEmail);
  
  
          //displaying logged in user name
          textViewUserEmail.setText("Welcome "+user.getEmail());
  
  
          buttonLogout.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  //logging out the user
                  firebaseAuth.signOut();
                  //closing activity
                  finish();
                  //starting login activity
                  startActivity(new Intent(ProfileActivity.this, SignUpActivity.class));
              }
          });
  
  
      }
  </code></pre>
  
  <p>When i press log out it just crashes with the msg beer app has stopped</p>