这段代码:
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
FirebaseUser user = task.getResult().getUser();
mMainViewModel.setGoogleLoginResult(user);
} else {
// If sign in fails, display a message to the user.
mMainViewModel.setGoogleLoginResult(null);
}
});
}
我从这里得到的:https://firebase.google.com/docs/auth/android/google-signin
在 Nougat 设备上工作得很好,但在 Oreo 设备上不工作。
这些是我的 build.gradle:
compileSdkVersion 28
buildToolsVersion '28.0.0'
// Firebase
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-auth:16.0.2"
implementation "com.google.firebase:firebase-database:16.0.1"
我已经在每台设备上都进行了调试;工作(牛轧糖)和不工作(奥利奥)但没有发现差异。
有什么线索吗?
最佳答案
在过去的几天里,我得到了 Firebase 团队的一些帮助,以及今天早上代码如何正常工作(在 Oreo 设备上)的一些帮助。我这边什么都没做,不知道他们做了什么。
关于Android Firebase 身份验证 : federated Google login not working in Oreo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50901611/