Runtime error when logging off android stuido mobile app

1 posts
Thanks Meter: 0
By Masudh_Deen, Junior Member on 24th June 2020, 03:29 PM
Post Reply Email Thread
I have a java mobile app that is connected with Firebase, login and registration works perfect. I only get an error when I try to logout from the Home Page/Activity. This is the error i get and I don't know what to do.

Attempt to invoke virtual method 'java.lang.String' on a null object reference at com.example.platformapp.HomeActivity.onCreate(Home

This is my code for the Home Activity/Page
public class HomeActivity extends AppCompatActivity {
Button btnLogout;
FirebaseAuth myFireBaseAuth;
TextView email;
FirebaseFirestore myfStore;
String userID;
private FirebaseAuth.AuthStateListener myAuthStateListener;

protected void onCreate(Bundle savedInstanceState) {
email = findViewById(;
myFireBaseAuth = FirebaseAuth.getInstance();
myfStore = FirebaseFirestore.getInstance();

userID = myFireBaseAuth.getCurrentUser().getUid(); // This is line 37

DocumentReference documentReference = myfStore.collection("users").document(userID);
documentReference.addSnapshotListener(this, new EventListener<DocumentSnapshot>() {
public void onEvent @nullable DocumentSnapshot documentSnapshot, @nullable FirebaseFirestoreException e) {
email.setText(documentSnapshot.getString("email")) ;

public void logout(View view)
startActivity(new Intent(getApplicationContext(),LoginActivity.class ));
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes