Reputation: 77
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);
}
Upvotes: 5
Views: 21062
Reputation: 1
I have used the Dependency Ver :9.6.1 for all firebase packages.
Then in my class I have included the following import:
import com.google.firebase.auth.AuthResult;
After Gradle Sync, the 'AuthResult' is no longer highlighted RED
Upvotes: 0
Reputation: 1474
Change your version of firebase for the latest, this worked for me in flutter adding in pubspec.yml
firebase_auth: ^0.15.0+1
Upvotes: 1
Reputation: 957
make the changes to this file build.gradle(Module: app)
You can solve this by providing the latest version possible for each package.
NOTE: they do not all need to be the same...mine for example goes like this...
compile 'com.google.firebase:firebase-core:16.0.1'
compile 'com.google.firebase:firebase-auth:16.0.2'
compile 'com.google.android.gms:play-services-gcm:15.0.1'
when done editing the file, click on sync gradle. And as at this time of writing, i am using android studio 3.1.3, and when you sync, the lint will let you know if there's a newer version, you can simply make changes to the version numbers and sync again.
Upvotes: 0
Reputation: 1
Add below listed in app gradle and then sync
compile 'com.google.firebase:firebase-auth:11.0.1'
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
Upvotes: 0
Reputation: 1
Try full path of package com.google.firebase.auth.AuthResult instead of AuthResult.
why? I can't explain. It worked for me.
Upvotes: -1
Reputation: 43
Please add
compile 'com.google.firebase:firebase-messaging:11.0.1
at build.gradle and try to recompile again.
I had used the below code snipped for creating user id and password
FirebaseUser currentUser= FirebaseAuth.getInstance().getCurrentUser();
if(currentUser ==null)
{
startActivity(new Intent(this,FirebaseAuthActivity.class));
finish();
return;
}
TextView email=(TextView) findViewById(R.id.email);
TextView displayName= (TextView) findViewById(R.id.displayName);
email.setText(currentUser.getEmail());
displayName.setText(currentUser.getDisplayName());
Upvotes: 0
Reputation: 54
Add this version in your Dependecy. I faced this problem too. but finally solved this by adding :
compile 'com.google.firebase:firebase-messaging:9.2.0'
Upvotes: 0
Reputation: 197
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
Upvotes: 5
Reputation: 637
I have some suggestions which might help :
1) add the google repository from the SDK Manager.
2) Per requirements for FireBase, Android Studio should be higher than 1.5
3) Gradle dependencies for FireBase must be correct and consistent.
4) Clean and Build and build once again with/without Android Studio restart.
Hope this helps.
Upvotes: 0