Firebase .getUID NullPointerException quando authen

Adicionarei dados ao banco de dados quando me registrar, mas recebi

Java.lang.NullPointerException: tentativa de chamar o método virtual 'java.lang.String com.google.firebase.auth.FirebaseUser.getUid ()' em uma referência de objeto nulo

Eu tento alguma coisa, mas não funciona

Aqui está o meu código

    auth = FirebaseAuth.getInstance();

    database = FirebaseDatabase.getInstance();

    mRef = database.getReference();
    FirebaseUser user = auth.getCurrentUser();
    userID = user.getUid();
btnSignUp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String fname = etFname.getText().toString().trim();
            final String lname = etLname.getText().toString().trim();
            final String id_card = etIdCard.getText().toString().trim();
            final String email = etEmail.getText().toString().trim();
            final String mobile = etMobile.getText().toString().trim();
            String password = etPassword.getText().toString().trim();

            if (TextUtils.isEmpty(email)){
                Toast.makeText(getApplicationContext(), "Enter email address!", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(password)){
                Toast.makeText(getApplicationContext(), "Enter password!", Toast.LENGTH_SHORT).show();
                return;
            }

            if (TextUtils.isEmpty(fname)){
                Toast.makeText(getApplicationContext(), "Enter FirstName!", Toast.LENGTH_SHORT).show();
                return;
            }

            if (password.length() < 8) {
                Toast.makeText(getApplicationContext(), "Password too short, enter minimum 8 characters!", Toast.LENGTH_SHORT).show();
                return;
            }

            progressBar.setVisibility(View.VISIBLE);

            auth.createUserWithEmailAndPassword(email,password)
                    .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task) {


                            if (!task.isSuccessful()) {

                                UserInfo userInfo = new UserInfo(fname,lname,id_card,mobile,email);
                                mRef.child("users").child(userID).setValue(userInfo);
                                etFname.setText("");
                                etLname.setText("");
                                etIdCard.setText("");
                                etMobile.setText("");
                                etEmail.setText("");
                                Toast.makeText(RegisterActivity.this, "Authentication failed." + task.getException(),
                                        Toast.LENGTH_SHORT).show();

                            } else {
                                Toast.makeText(RegisterActivity.this, "Register Successfully" + task.isSuccessful(), Toast.LENGTH_SHORT).show();
                                progressBar.setVisibility(View.GONE);

                                finish();
                            }

                        }
                    });
        }
    });


}

E agora obtenha um novo erro como este java.lang.NoSuchMethodError: Nenhum método virtual zzTt () Z na classe Lcom / google / firebase / FirebaseApp; ou suas super classes (a declaração de 'com.google.firebase.FirebaseApp' aparece em /data/app/com.example.androiddev.army31-1/split_lib_dependencies_apk.apk:classes36.dex)

Agora posso corrigi-lo, porque compilar no gradle não é a mesma versão

E tem a mesma coisa

questionAnswers(3)

yourAnswerToTheQuestion