My app was working perfectly before until this morning when I ran my code in android studio and it crashed, I checked logcat and it pointed to these two places
first is in the MainActivity.java
in the onStart
mAuth = FirebaseAuth.getInstance();
mToolbar = findViewById(R.id.main_app_bar);
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle("ChatPlus");
BottomNavigationView navigation = findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
loadFragment(new RequestFragment());
if (mAuth.getCurrentUser() != null) {
mUserRef = FirebaseDatabase.getInstance().getReference().child("Users").child(mAuth.getCurrentUser().getUid());
}
}
@Override
public void onStart() {
super.onStart(); //crashes here
// Check if user is signed in (non-null) and update UI accordingly.
FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser == null) {
sendtostart();
} else {
mUserRef.child("online").setValue("true");
}
}
@Override
protected void onStop() {
super.onStop();
FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser != null) {
mUserRef.child("online").setValue(ServerValue.TIMESTAMP);
}
}
second place is in my RequestFragment
mMainView = inflater.inflate(R.layout.fragment_request, container, false);
mRequestList = (RecyclerView) mMainView.findViewById(R.id.request_list);
mAuth = FirebaseAuth.getInstance();
mCurrent_user_id = mAuth.getCurrentUser().getUid(); //at this line
mRequestDatabase = FirebaseDatabase.getInstance().getReference().child("Friend_req").child(mCurrent_user_id);
mRequestDatabase.keepSynced(true);
mUsersDatabase = FirebaseDatabase.getInstance().getReference().child("Users");
mUsersDatabase.keepSynced(true);