I am doing a class and I try to register the email and password, from that code, in the firebase, but it is not created. I can not get this authentication.
The database I created to test whether I was able to "communicate" with the firebase and ran accordingly. I have already enabled the login by email and password in the Firebase settings, but the logins I do not appear.
public class MainActivity extends AppCompatActivity {
private FirebaseAuth firebaseAuth;
private DatabaseReference firebaseReferencia = FirebaseDatabase.getInstance().getReference();
private DatabaseReference usuarioReferencia = firebaseReferencia.child("Usuários");
private DatabaseReference produtoReferencia = firebaseReferencia.child("Produtos");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//usuarioReferencia.child("002").child("Nome").setValue("Mariana");
firebaseAuth = FirebaseAuth.getInstance();
//Cadastro
firebaseAuth.createUserWithEmailAndPassword(email, senha)
.addOnCompleteListener(MainActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if ( task.isSuccessful() ){//Sucesso ao cadastrar usuario
Log.i("CreateUser", "Sucesso ao cadastrar usuário!");
}else{
Log.i("CreateUser", "Erro ao cadastrar usuário!");
}
}
});
}
}
build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.2.0'
App
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.google.firebase:firebase-core:12.0.1'
compile 'com.google.firebase:firebase-auth:12.0.1'
compile 'com.google.firebase:firebase-database:12.0.1'
compile 'com.google.android.gms:play-services-auth:12.0.1'
}
apply plugin: 'com.google.gms.google-services'