我一直在浏览 Firebase 文档以在我的 Android 应用程序中设置用户身份验证系统。然而,由于某种原因,我的 FirebaseAuth 对象上似乎没有运行任何回调!
例如,按照说明设置 Facebook 身份验证here https://firebase.google.com/docs/auth/android/facebook-login
private void handleFacebookAccessToken(AccessToken token) {
Log.d("AUTH", "handleFacebookAccessToken:" + token.getToken());
// ...
AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
Log.d("AUTH", "Credential: "+credential);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d("AUTH", "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.w("AUTH", "signInWithCredential", task.getException());
Toast.makeText(LoginActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
// ...
}
});
}
Facebook 方面一切正常,但当使用检索到的 Facebook 凭据登录时,signInWithCredential 函数不会运行任何回调,并且我的用户数据库中似乎没有发生任何情况。
此外我尝试过更简单的方法
mAuth.createUserWithEmailAndPassword(etUserID.getText().toString(), etPassword.getText().toString());
也什么也没发生。我已在 Firebase 控制台中启用了这两个提供程序,并下载了该项目的最新 google-services.json 文件。我错过了什么吗?
编辑:刚刚尝试运行快速启动身份验证演示,但效果不佳。我确实在模拟器上看到,除非我更新谷歌服务,否则该应用程序将无法运行。这是这个错误的原因吗?我尝试在各种模拟器上更新谷歌服务,但这只是返回一个错误。