Email and password in Android Studio application does not register in Firebase

0

I do not see any type of error when I click to register the button, I have already put all types of password sizes and I have put up my own valid email only that does not register in firebase authentication.

private void Cadastrar() {

    nome = (EditText) findViewById(R.id.edit_cadastro_nome);
    email = (EditText) findViewById(R.id.edit_cadastro_email);
    senha = (EditText) findViewById(R.id.edit_cadastro_senha);
    botaoCadastar = (Button) findViewById(R.id.bt_cadastrar);

    botaoCadastar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            usuario = new Usuario();
            usuario.setNome(nome.getText().toString());
            usuario.setEmail(email.getText().toString());
            usuario.setSenha(senha.getText().toString());
            cadastarUsuario();
        }
    });
}

private void cadastarUsuario(){

    autenticacao = ConfiguracaoFireBase.getFirebaseAutenticacao();
    autenticacao.createUserWithEmailAndPassword(
            usuario.getEmail(),
            usuario.getSenha()
    ).addOnCompleteListener(CadastroUsuarioActivity.this, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            if(task.isSuccessful()){
                Toast.makeText(CadastroUsuarioActivity.this,"Sucesso ao cadastrar", Toast.LENGTH_LONG).show();
                Log.i(usuario.getEmail(), "Erro");
            }else{
                Toast.makeText(CadastroUsuarioActivity.this,"Erro ao cadastrar", Toast.LENGTH_LONG).show();
            }

        }
    });
}

FIREBASE CONFIGURATION

public final class ConfiguracaoFireBase {

    private static DatabaseReference referenciaFirebase;
    private static FirebaseAuth autenticacao;

    public static DatabaseReference getFirebase() {

        if (referenciaFirebase == null) {
            referenciaFirebase = FirebaseDatabase.getInstance().getReference();
        }

        return referenciaFirebase;
    }

    public static FirebaseAuth getFirebaseAutenticacao(){

        if(autenticacao == null){
            autenticacao = FirebaseAuth.getInstance();
        }
        return autenticacao;
    }
}
    
asked by anonymous 15.12.2017 / 18:21

2 answers

1

Maybe your firebase rules file is restricting the insertion.

Take a look at this link and see if it will help you.

    
15.12.2017 / 19:19
0

I do not see any problems in the code.

Perhaps what is missing is to enable the email / password authentication option in Firebase.

    
16.12.2017 / 19:46