当处理签名google活动的返回时,我有以下错误:
02-13 23:53:33.729 14395-14395 / br.com.easytrip E / AndroidRuntime:FATAL EXCEPTION:main 处理:br.com.easytrip,PID:14395 java.lang.RuntimeException:将结果ResultInfo {who = null,request = 711,result = -1,data = Intent {(has extras)}}传递给activity {br.com.easytrip / br.com.easytrip.features .login.view.LoginGoogleActivity}:com.google.android.gms.common.api.ApiException:8: 在android.app.ActivityThread.deliverResults(ActivityThread.java:4130) 在android.app.ActivityThread.handleSendResult(ActivityThread.java:4173) 在android.app.ActivityThread.-wrap20(ActivityThread.java) 在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1546) 在android.os.Handler.dispatchMessage(Handler.java:102) 在android.os.Looper.loop(Looper.java:154) 在android.app.ActivityThread.main(ActivityThread.java:6165) at java.lang.reflect.Method.invoke(Native Method) 在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:888) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778) 引起:com.google.android.gms.common.api.ApiException:8: 在com.google.android.gms.common.internal.zzb.zzy(未知来源) 在com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(未知来源) at br.com.easytrip.features.login.view.LoginGoogleActivity.onActivityResult(LoginGoogleActivity.kt:46) 在android.app.Activity.dispatchActivityResult(Activity.java:6946) 在android.app.ActivityThread.deliverResults(ActivityThread.java:4126) 在android.app.ActivityThread.handleSendResult(ActivityThread.java:4173) 在android.app.ActivityThread.-wrap20(ActivityThread.java) 在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1546) 在android.os.Handler.dispatchMessage(Handler.java:102) 在android.os.Looper.loop(Looper.java:154) 在android.app.ActivityThread.main(ActivityThread.java:6165) at java.lang.reflect.Method.invoke(Native Method) 在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:888) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
onActivityResult的代码段:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK && requestCode == GOOGLE_SIGN_IN_REQUEST) {
data?.let {
val signedInAccountFromIntent = GoogleSignIn.getSignedInAccountFromIntent(intent)
presenter.handleGoogleLogin(signedInAccountFromIntent)
} ?: handleGoogleSignInError()
} else {
handleGoogleSignInError()
}
}
我的谷歌登录意图的代码片段:
private fun setUp() {
val googleSignInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build()
googleSignInClient = GoogleSignIn.getClient(this, googleSignInOptions)
val account = GoogleSignIn.getLastSignedInAccount(this)
if (account != null && account.idToken != null) {
account.idToken?.let{
setResult(it)
} ?: showGenericError()
} else {
val signInIntent = googleSignInClient.signInIntent
startActivityForResult(signInIntent, GOOGLE_SIGN_IN_REQUEST)
}
}
我在firebase控制台中添加了一个sha1调试密钥。