This error commonly occur in Firebase ,when we are tring to call the mAuth.getCurrentUser().getUid(); which is initialized otside the caller Function. To fix this error we have to initialize this" mAuth.getCurrentUser().getUid(); "inside the Caller Function.
In my case if String id = mAuth.getCurrentUser().getUid(); is declared outside the mAuth.createUserWithEmailAndPassword(emaill,pass).addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if(task.isSuccessful()) {}); function then....the Attempt to invoke virtual method ......error occur...