目前正尝试将我的游戏(使用libgdx)连接到Google游戏服务以启用排行榜/成就等,并看到一些奇怪的行为。
问题
当我第一次点击“登录”时,会显示选择您的Google帐户的对话框,然后播放服务权限圈子对话框,然后是大加载圈子。过了一会儿,它会显示一个对话框,出现以下错误 Google Play服务的未知问题
如果我点击“确定”关闭该错误对话框,再次点击“登录”按钮,我立即成功登录。之后,我可以看到排行榜等。
详情
我看到的错误日志:
...
D: GameHelper: onActivityResult: req=RC_RESOLVE, resp=9001
D: GameHelper: onAR: responseCode=9001, so giving up.
D: GameHelper: killConnections: killing connections.
D: GameHelper: killConnections: all clients disconnected.
D: GameHelper: State change CONNECTING -> DISCONNECTED
D: GameHelper: Making error dialog for failure: SignInFailureReason(serviceErrorCode:SIGN_IN_REQUIRED(4),activityResultCode:9001)
D: GameHelper: Showing error dialog.
D: GameHelper: Notifying LISTENER of sign-in FAILURE (error)
I: ----- Sign in failed :( -----
///// Tap the 'sign in' button again ///////
I: ----- Begin sign in process... -----
D: GameHelper: Starting USER-INITIATED sign-in flow.
D: GameHelper: isGooglePlayServicesAvailable returned 0
D: GameHelper: beginUserInitiatedSignIn: starting new sign-in flow.
D: GameHelper: Starting connections.
D: GameHelper: State change DISCONNECTED -> CONNECTING
D: GameHelper: connectNextClient: requested clients: 1, connected clients: 0
D: GameHelper: Pending clients: 1
D: GameHelper: Connecting GamesClient.
D: GameHelper: onConnected: connected! client=1
D: GameHelper: Connected clients updated to: 1
D: GameHelper: connectNextClient: requested clients: 1, connected clients: 1
D: GameHelper: Pending clients: 0
D: GameHelper: All clients now connected. Sign-in successful!
D: GameHelper: All requested clients connected. Sign-in succeeded!
D: GameHelper: State change CONNECTING -> CONNECTED
D: GameHelper: Notifying LISTENER of sign-in SUCCESS
I: ----- Sign in success! -----
D: GameHelper: onActivityResult: req=3, resp=3
D: GameHelper: onActivityResult: request code not meant for us. Ignoring.
...
由于我使用的是libgdx,我没有扩展BaseGameActivity
,而是手动创建GameHelper
并使用它代替
// in @Override onCreate:
mGameHelper = new GameHelper(this);
mGameHelper.setup(this, GameHelper.CLIENT_GAMES);
mGamesClient = mGameHelper.getGamesClient();
// in @Override onStart:
mGameHelper.onStart(this);
// then, for the sign in button, using it:
mGameHelper.beginUserInitiatedSignIn();
额外信息
我也在日志中看到以下内容:
E: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
但是,不确定它是否相关,从我读过的内容来看,这似乎与map / gps / location有关。不使用地图,我可以登录,所以不确定这个错误是否相关(虽然听起来确实很糟糕!)
更新/修改 :测试后,此错误是由AdMob(我已与Google服务集成)引起的。虽然错误听起来不好,但是禁用AdMob(没有更多错误),奇怪的行为仍然是相同的。
我认为以下是有趣的错误日志,虽然没有太多运气谷歌搜索此错误:
E/dalvikvm( 2618): Could not find class 'android.app.AppOpsManager', referenced from method axo.a
编辑2 :更多调查结果!
即使我没有完成整个登录工作流程,我也会得到相同的错误对话框。
任何帮助都会很棒!
注意:
onActivityResult
答案 0 :(得分:3)
想出来!它最终成了一个愚蠢的错误!
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// mGameHelper.onActivityResult(requestCode, requestCode, data); // before - broken
mGameHelper.onActivityResult(requestCode, resultCode, data); // after - working! \o/
}
看到区别? (提示:mGameHelper.onActivityResult
的第二个参数)
为了将来其他人的利益,以下日志虽然可能表明其他错误,但似乎不会影响登录过程 - 或者一般的游戏服务 - 我的排行榜正在运行:)
E / GooglePlayServicesUtil(10033):找不到Google Play服务资源。检查项目配置以确保包含资源。
根据我的调试,这与使用AdMob和Google Play服务有关。 AdMob可能会尝试获取基于位置的信息(所有其他Google搜索上述错误都会导致地图相关问题)
E / dalvikvm(10100):找不到类'android.app.AppOpsManager',引自方法axp.a
不确定这个错误是什么。 android.app.AppOpsManager
似乎是API v19(AppOpsManager in Android Developer)中添加的类。我将SDK更改为使用API v19,但仍然出现此错误。快速浏览文档表明它还具有与位置相关的功能(可能再次使用AdMob - 我不认为我在禁用AdMob时看到了这一点)
答案 1 :(得分:2)
您是否通过此链接激活了api:https://console.developers.google.com/project ?
答案 2 :(得分:0)
该应用必须使用相同的文件进行签名并上传到手机并播放为测试版,才能使用Google服务
答案 3 :(得分:0)
我从GameHelper onStop方法中删除了这一行。
// mExpectingResolution = false。
它为我工作
https://code.google.com/p/play-games-platform/issues/detail?id=98