我正在尝试集成Google Play游戏服务,但无法登录。我知道一些开发者之前问过这个问题,但问题是没有人问我遇到的错误。
日志如下:
Must have a game ID to sign in! Status{statusCode=unknown status code: 12501, resolution=null} Invalid (empty) game ID found in the EXTRA_GAME_ID extra.
我只是按照官方文档上的教程进行操作。 可能导致该错误的原因是什么?似乎没有人问过这个错误,这很奇怪。每个人都有一些状态码,但我的只是未知。是否有人遇到过这个错误?
代码
清单
日志如下:
Must have a game ID to sign in! Status{statusCode=unknown status code: 12501, resolution=null} Invalid (empty) game ID found in the EXTRA_GAME_ID extra.
我只是按照官方文档上的教程进行操作。 可能导致该错误的原因是什么?似乎没有人问过这个错误,这很奇怪。每个人都有一些状态码,但我的只是未知。是否有人遇到过这个错误?
代码
清单
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="...">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:roundIcon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
...
Activity
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()) {
Log.e("e", result.getStatus());
message = "Something wrong happened. Please try again.";
}
new AlertDialog.Builder(this, R.style.CustomAlertDialogTheme).setMessage(message)
.setNeutralButton(android.R.string.ok, null).show();
}
}
}
res/values/ids.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="app_id" type="string">digits here...</item>
</resources>
我确定我已经将我的应用链接到Play游戏服务。我在Play控制台上将自己添加为测试人员(包括游戏服务部分和发布管理部分)。我尝试了实际设备和模拟器两种方式。我没有在API控制台上手动创建OAuth2客户端ID,而是从Play控制台创建的。SHA-1是正确的(如果不正确,我应该会收到其他错误消息)。从未起作用。