Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase AuthResult on task shows cannot resolve symbol

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);
}
like image 900
Hariharsudan Saravanane Avatar asked Oct 24 '16 18:10

Hariharsudan Saravanane


2 Answers

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

like image 117
Chandan Avatar answered Nov 15 '22 14:11

Chandan


Change your version of firebase for the latest, this worked for me in flutter adding in pubspec.yml

firebase_auth: ^0.15.0+1
like image 29
Pedro Molina Avatar answered Nov 15 '22 15:11

Pedro Molina