我刚刚完成了我的应用程序并生成了一个已签名的apk并将apk上传到游戏商店作为alpha测试。
除Google游戏服务外,其他所有内容似乎都按预期运行。我看到绿色框连接到谷歌播放服务,然后是一个绿色微调器几秒钟但它继续失败,logcat中显示以下消息
ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{3b445e29: android.os.BinderProxy@6050db6}, message=null}
当我从android studio运行我的应用程序时,它可以正常工作吗?
以下是我的连接代码:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(connectCallback)
.addOnConnectionFailedListener(connectFailed)
.addApi(Games.API, gamesOptions).addScope(Games.SCOPE_GAMES)
.build();
mGoogleApiClient.connect();
答案 0 :(得分:1)
在我的情况下问题是测试未激活,如此处所示“https://developers.google.com/games/services/android/troubleshooting”检查测试帐户是否已启用。启用beta测试版后,它可以工作。
答案 1 :(得分:0)
这是因为当您第一次安装应用程序时,您需要登录Google Play服务。您需要实现以下回调方法:
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.d(TAG, "onConnectionFailed() called, result: " + connectionResult);
if (mResolvingConnectionFailure) {
Log.d(TAG, "onConnectionFailed() ignoring connection failure; already resolving.");
return;
}
if (mSignInClicked || mAutoStartSignInFlow) {
mAutoStartSignInFlow = false;
mSignInClicked = false;
mResolvingConnectionFailure = BaseGameUtils.resolveConnectionFailure(this, mGoogleApiClient,
connectionResult, RC_SIGN_IN, getString(R.string.signin_other_error));
}
switchToScreen(R.id.screen_sign_in);
}
@Override
public void onActivityResult(int requestCode, int responseCode,
Intent intent) {
super.onActivityResult(requestCode, responseCode, intent);
switch (requestCode) {
case RC_SIGN_IN:
Log.d(TAG, "onActivityResult with requestCode == RC_SIGN_IN, responseCode="
+ responseCode + ", intent=" + intent);
mSignInClicked = false;
mResolvingConnectionFailure = false;
if (responseCode == RESULT_OK) {
mGoogleApiClient.connect();
} else {
BaseGameUtils.showActivityResultError(this,requestCode,responseCode, R.string.signin_other_error);
}
break;
}
super.onActivityResult(requestCode, responseCode, intent);
}
您也可以参考示例项目https://github.com/playgameservices/android-basic-samples