当我尝试在Android上静默登录时,我经常收到以下错误。我该怎么调试呢这是什么原因。 (我的Android手机上有一个活跃的谷歌帐户。)
signInSilently(): failure
com.google.android.gms.common.api.ApiException: 4:
at com.google.android.gms.common.internal.zzb.zzz(Unknown Source)
at com.google.android.gms.common.internal.zzbk.zzaa(Unknown Source)
at com.google.android.gms.common.internal.zzbl.zzs(Unknown Source)
at com.google.android.gms.common.api.internal.zzs.zzc(Unknown Source)
at com.google.android.gms.common.api.internal.zzs.setResult(Unknown Source)
at com.google.android.gms.auth.api.signin.internal.zzg.zza(Unknown Source)
at com.google.android.gms.auth.api.signin.internal.zzt.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:446)
代码如下
mGoogleSignInClient.silentSignIn().addOnCompleteListener(activity,
new OnCompleteListener<GoogleSignInAccount>() {
@Override
public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
if (task.isSuccessful()) {
Log.d(TAG, "signInSilently(): success");
onConnected(task.getResult());
} else {
Log.d(TAG, "signInSilently(): failure", task.getException());
Toast.makeText(activity, "A sign-in problem encountered.",
Toast.LENGTH_SHORT).show();
onDisconnected();
}
}
});
答案 0 :(得分:1)
根据它,您的错误代码意味着:
public static final int SIGN_IN_REQUIRED
The client attempted to connect to the service but the user is not signed in. The client may choose to continue without using the API. Alternately, if hasResolution() returns true the client may call startResolutionForResult(Activity, int) to prompt the user to sign in. After the sign in activity returns with RESULT_OK further attempts should succeed.
Constant Value: 4
这意味着,用户需要先手动登录才能使用silentSignIn
。您可以找到示例on Google github
答案 1 :(得分:0)
我发生了这个错误,因为我没有将我正在测试的电子邮件添加到Google Play游戏控制台的测试人员标签。
我相信如果您的版本未使用与您生成的Google Play游戏应用ID相同的SHA1密钥进行签名,也会出现