java – Google Play游戏服务中的IllegalStateException没有意义

前端之家收集整理的这篇文章主要介绍了java – Google Play游戏服务中的IllegalStateException没有意义前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我在Play Market玩了一个游戏,然后我收到了消息和堆栈跟踪.

java.lang.IllegalStateException
Msg: (Not connected. Call connect() and wait for onConnected() to be called.)

java.lang.IllegalStateException
com.google.android.gms.internal.p.n(Unknown Source)
com.google.android.gms.internal.p.o(Unknown Source)
com.google.android.gms.internal.e.loadState(Unknown Source)
com.google.android.gms.appstate.AppStateClient.loadState(Unknown Source)
com.peerkesoftware.blockcrusher.CloudSave.load(CloudSave.java:31)
com.peerkesoftware.blockcrusher.CloudSave.setAppStateClient(CloudSave.java:26)
com.peerkesoftware.blockcrusher.MorburActivity.onSignInSucceeded(MorburActivity.java:475)
com.peerkesoftware.libgeneric.app.game.GameHelper.succeedSignIn(GameHelper.java:652)
com.peerkesoftware.libgeneric.app.game.GameHelper.connectNextClient(GameHelper.java:539)
com.peerkesoftware.libgeneric.app.game.GameHelper.onConnected(GameHelper.java:642)
com.google.android.gms.internal.p.k(Unknown Source)
com.google.android.gms.internal.bj.k(Unknown Source)
com.google.android.gms.internal.p$f.a(Unknown Source)
com.google.android.gms.internal.p$f.a(Unknown Source)
com.google.android.gms.internal.p$b.p(Unknown Source)
com.google.android.gms.internal.p$a.handleMessage(Unknown Source)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:132)
android.app.ActivityThread.main(ActivityThread.java:4126)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:491)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
dalvik.system.NativeStart.main(Native Method)

奇怪的是消息说我应该调用connect()并等待onConnected().但正如您在stacktrace中看到的那样,调用来自onConnected().所以我确定谷歌播放服务已经连接.为什么我仍然会收到IllegalStateException?我没有意义.

最佳答案
有些情况下,即使正确使用API​​,android.gms.internal也会抛出IllegalStateException.例如.下面的跟踪记录了所有客户端连接的情况,并且正在处理google的successSignIn()回调到我们获得该异常的代码. (SwGameHelper是我们google的GameHelper代码的副本)

请注意,gms.internal堆栈跟踪似乎包含一些名为“signOut”的方法.所以这可能是谷歌代码的一个错误,但我的猜测是连接后连接丢失的竞争条件.我不得不在其他连接服务上处理类似的比赛.如果这是一场比赛谷歌可能只需要更好地记录他们的方法可以抛出这个异常,即使你在调用它们时已连接.

我正在考虑解决这个问题的方法.如果我找到一个好的修复程序,我会更新.

这是我们最常见的安装客户崩溃错误之一,所以它并不罕见.

onConnected: connected! client=1 com.lootworks.swords.screens.SwGameHelper
Connecting PlusClient. com.lootworks.swords.screens.SwGameHelper
onConnected: connected! client=2 com.lootworks.swords.screens.SwGameHelper
All clients now connected. Sign-in successful. com.lootworks.swords.screens.SwGameHelper
All requested clients connected. Sign-in succeeded! com.lootworks.swords.screens.SwGameHelper

java.lang.IllegalStateException: Not connected. Call connect() and wait for onConnected() to be called.
    at com.google.android.gms.internal.p.n(Unknown Source)
    at com.google.android.gms.internal.p.o(Unknown Source)
    at com.google.android.gms.internal.bj.a(Unknown Source)
                                       loadAchievements
                                       b
                                       a
                                       signOut
                                       a
                                       a
    at com.google.android.gms.games.GamesClient.loadAchievements(Unknown Source)
                                             signOut
    at com.lootworks.swords.social.SwAchievementManager.loadAndUploadAchievements(SourceFile:441)
    at com.lootworks.swords.activity.SwMap3D.onSignInSucceeded(SourceFile:3526)
    at com.lootworks.swords.screens.SwGameHelper.succeedSignIn(SourceFile:639)
    at com.lootworks.swords.screens.SwGameHelper.connectNextClient(SourceFile:530)
    at com.lootworks.swords.screens.SwGameHelper.onConnected(SourceFile:629)
    at com.google.android.gms.internal.p.k(Unknown Source)
    at com.google.android.gms.internal.bj.k(Unknown Source)
    at com.google.android.gms.internal.p$f.a(Unknown Source)
    at com.google.android.gms.internal.p$f.a(Unknown Source)
    at com.google.android.gms.internal.p$b.p(Unknown Source)
    at com.google.android.gms.internal.p$a.handleMessage(Unknown Source)
    at android.os.Handler.dispatchMessage(Handler.java:99)
原文链接:https://www.f2er.com/android/430880.html

猜你在找的Android相关文章