Getting red line over Task. I have imported import com.google.firebase.auth.AuthResult;
too, yet it shows cannot resolve symbol authresult
in that too.
auth = FirebaseAuth.getInstance();
sign_up_button = (Button) findViewById(R.id.sign_up_button);
email = (EditText) findViewById(R.id.email);
password = (EditText) findViewById(R.id.password);
sign_up_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email_a = email.getText().toString().trim();
String password_a = password.getText().toString().trim();
//create user
auth.createUserWithEmailAndPassword(email_a, password_a)
.addOnCompleteListener(RegisterStaff.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Toast.makeText(RegisterStaff.this, "Registration Complete..:" + task.isSuccessful(), Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.GONE);
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful()) {
Toast.makeText(RegisterStaff.this, "Registration failed..." + task.getException(),
Toast.LENGTH_SHORT).show();
} else {
startActivity(new Intent(RegisterStaff.this, StaffLogin.class));
finish();
}
}
}
);}
});
}
@Override
protected void onResume() {
super.onResume();
progressBar.setVisibility(View.GONE);
}
make sure you compile the same version of authresult as core like :-
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
all are same 10.0.1
Change your version of firebase for the latest, this worked for me in flutter adding in pubspec.yml
firebase_auth: ^0.15.0+1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With