private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
Log.d(TAG, "firebaseAuthWithGooogle:" + acct.getId());
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
mFirebaseAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());
// 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()) {
Log.e(TAG, "signInWithCredential", task.getException());
Toast.makeText(SignInActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show();
} else {
startActivity(new Intent(SignInActivity.this, MainActivity.class));
finish();
}
}
});
}
I posted the same question to Firebase support team, they suggested to clear Play Services Storage data and cache, as soon as I cleared them, the App started to worked as expected and allowed to login using a valid Google Account!
Follow the below step if you run into an exception or error similar to "FIREBASE_AUTH_API is not available on this device" !
--> Clear Google Play Services cache and try again after a few minutes (Settings > Apps > Google Play services > Storage > Manage Space > Clear All Data).
compile 'com.google.firebase:firebase-auth:9.0.2'
(ensure your Google repository is up to date using the SDK Manager)compile 'com.google.firebase:firebase-auth:9.0.2'
(ensure your Google repository is up to date using the SDK Manager)--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/81919ad9-0bd8-4141-94ba-aa164b0b7bc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I updated my firebase auth to 9.0.2 and cleared data and cache in Google Play Services but I still have the same error.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();