在onConnectionFailed GameHelper崩溃() [英] GameHelper crashes on onConnectionFailed()

查看:157
本文介绍了在onConnectionFailed GameHelper崩溃()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下暴跌 GameHelper.java

[主]在显示java.lang.NullPointerException   com.google.android.gms.common.ConnectionResult.startResolutionForResult(未知   源)以   com.google.example.games.basegameutils.GameHelper.resolveConnectionResult(GameHelper.java:752)     在   com.google.example.games.basegameutils.GameHelper.onConnectionFailed(GameHelper.java:729)

[main] java.lang.NullPointerException at com.google.android.gms.common.ConnectionResult.startResolutionForResult(Unknown Source) at com.google.example.games.basegameutils.GameHelper.resolveConnectionResult(GameHelper.java:752) at com.google.example.games.basegameutils.GameHelper.onConnectionFailed(GameHelper.java:729)

我认为可能发生的唯一原因是,如果 mActivity == NULL GameHelper.java:752

The only reason I think that could happen is if mActivity == null at GameHelper.java:752:

mConnectionResult.startResolutionForResult(mActivity, RC_RESOLVE);

mActivity 沾到的onStop空() 难道GameHelper.java有错误,会崩溃,如果 onConnectionFailed()后的onStop 发生()被称为? 谢谢你。

mActivity gets null on onStop() Is it possible that GameHelper.java has bug and can crash if onConnectionFailed() happens after onStop() is called? Thanks.

编辑: 这事发生更新到最新的游戏API(恢复15)后,连同更新GameHelper.java。

EDITED: It happened after update to the latest Play API (rev 15) together with the updated GameHelper.java.

推荐答案

编辑:

现在,这已在最新GameHelper版本: <一href="https://github.com/playgameservices/android-samples/commit/e7b3758c136b5b434f1dfd9ca8c03f75aad70f09">https://github.com/playgameservices/android-samples/commit/e7b3758c136b5b434f1dfd9ca8c03f75aad70f09

This now has been fixed in latest GameHelper version: https://github.com/playgameservices/android-samples/commit/e7b3758c136b5b434f1dfd9ca8c03f75aad70f09

OLD答:

对于我来说,发生在应用程序的开始,当谷歌播放服务要求我签的,如果我点击取消,同样的错误发生。

For me it happens on the start of the app, when Google Play Services asks me to sign in and if I click cancel, this same error happens.

所以,从你自己的活动离开时,在活动的签署,将分派的onStop事件,并没有因为用户启动过程,这是解析的连接,从而错误发生。

So when leaving from your own activity to sign in activity, it dispatches onStop event, and fails to connect because of the user initiated process, which is resolvable, thus the error happens.

所以,我快速的黑客正在改变:

So my quick hack was changing:

catch (SendIntentException e)

简单地

catch (Exception e)

因此​​,它也将赶上空指针异常 当然,在这种情况下,注册过程可能无法继续,所以我initate重新登录的另一个动作,似乎工作了。

So it would also catch Null pointer exception Of course in this case the signup process might not proceed, so I initate relogin on another action and it seems to work for now.

更彻底的黑客可能试图解决在活动启动的结果,为我们定义等待解决变量:

More thorough hack could be trying to resolve the result on activity start, for that we define pending resolution variable:

// Are we expecting the result of a resolution flow?
boolean mExpectingResolution = false;
boolean mPendingResolution = false;

然后在错误行,我们检查,如果活动不为空

Then on the error line we check if activity is not null

if(mActivity != null)
    mConnectionResult.startResolutionForResult(mActivity, RC_RESOLVE);
else
    mPendingResolution = true;

和上开始我们检查,并尝试解决它:

And on start we check and try to resolve it:

if(mPendingResolution && mConnectionResult != null)
try {
    mConnectionResult.startResolutionForResult(mActivity, RC_RESOLVE);
} catch (SendIntentException e) {
    e.printStackTrace();
}

这应该有助于直到LIB支持者官方分辨率:)

This should help until the official resolution from lib supporters :)

这篇关于在onConnectionFailed GameHelper崩溃()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆