我正在开发一款在Android Studio上使用Google Play Games服务的应用程序,包括成就和排行榜,但是我在尝试登录时遇到了错误。 我遵循了文档中的说明,所有密钥和OAuth代码都匹配,但我仍然在尝试登录时收到此错误信息:
我已经到处查找答案,重新启动了所有凭据,取消发布并重新发布了所有新内容,检查了所有ID。 如果有人能给我一些建议,我将不胜感激。com.google.android.gms.common.api.ApiException: 4: 4:
com.google.android.gms.common.api.ApiException: 4: 4:
at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source)
at com.google.android.gms.common.internal.zai.zaf(Unknown Source)
at com.google.android.gms.common.internal.zaj.onComplete(Unknown Source)
at com.google.android.gms.common.api.internal.BasePendingResult.zaa(Unknown Source)
at com.google.android.gms.common.api.internal.BasePendingResult.setResult(Unknown Source)
at com.google.android.gms.auth.api.signin.internal.zzj.zzc(Unknown Source)
at com.google.android.gms.auth.api.signin.internal.zzt.dispatchTransaction(Unknown Source)
at com.google.android.gms.internal.auth-api.zzd.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:461)
这是从Google文档中用于登录的代码。
private void startSignInIntent() {
GoogleSignInClient signInClient = GoogleSignIn.getClient(
this, GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN
);
Intent intent = signInClient.getSignInIntent();
startActivityForResult(intent, RC_SIGN_IN);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result =
Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// The signed in account is stored in the result.
GoogleSignInAccount signedInAccount = result.getSignInAccount();
} else {
String message = result.getStatus().getStatusMessage();
if (message == null || message.isEmpty()) {
message = getString(R.string.signin_other_error);
}
new AlertDialog.Builder(this)
.setMessage(message)
.setNeutralButton(android.R.string.ok, null)
.show();
}
}
}