Reputation: 173
I'm following a tutorial on how to make registration using firebase and i copy paste the code from firebase tools which is the "sign up new users" and it show error "error: cannot find symbol class OnCompleteListener"
I've tried to change the version on dependency but it doesn't solve the issue.
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Toast.makeText(getApplicationContext(), "Registration successful!", Toast.LENGTH_LONG).show();
progressBar.setVisibility(View.GONE);
Intent intent = new Intent(RegistrationActivity.this, LoginActivity.class);
startActivity(intent);
}
else {
Toast.makeText(getApplicationContext(), "Registration failed! Please try again later", Toast.LENGTH_LONG).show();
progressBar.setVisibility(View.GONE);
}
}
});
expected android studio to recognize the symbol but its not
Upvotes: 1
Views: 1799
Reputation: 317362
OnCompleteListener is part of the Play Services Task API. You can find the JavaDoc for that class here. It's not terribly clear from the JavaDoc, but the package of the class is com.google.android.gms.tasks, and you can import it as such:
import com.google.android.gms.tasks.OnCompleteListener;
Upvotes: 2
Reputation: 401
Add this on build.gradle (app)
apply plugin: 'com.google.gms.google-services'
android {
...
}
dependencies {
...
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
}
and dont forget to import this
import com.google.android.gms.tasks.OnCompleteListener;
hope this help..
Upvotes: 4