IabHelper Service not registered导致的闪退

java.lang.IllegalArgumentException

Service not registered: com.gcrest.gpublib.util.IabHelper$1@431f9da0

java.lang.RuntimeException:Unable to destroy activity {com.bilibili.meng.wdj/org.cocos2dx.cpp.AppActivity}: java.lang.IllegalArgumentException: Service not registered: com.gcrest.gpublib.util.IabHelper$1@431f9da0
android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3754)
......
cause by:
java.lang.IllegalArgumentException:Service not registered: com.gcrest.gpublib.util.IabHelper$1@431f9da0
android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:992)
android.app.ContextImpl.unbindService(ContextImpl.java:1676)
android.content.ContextWrapper.unbindService(ContextWrapper.java:529)
com.gcrest.gpublib.util.IabHelper.dispose(IabHelper.java:300)
com.gcrest.gpublib.AppBillingManager.destruction(AppBillingManager.java:466)
org.cocos2dx.cpp.AppActivity.onDestroy(AppActivity.java:149)
android.app.Activity.performDestroy(Activity.java:5486)
android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1120)
android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3741)
android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3772)
android.app.ActivityThread.access$1700(ActivityThread.java:139)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
android.os.Handler.dispatchMessage(Handler.java:102)
android.os.Looper.loop(Looper.java:136)
android.app.ActivityThread.main(ActivityThread.java:5314)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:515)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:678)

dalvik.system.NativeStart.main(Native Method)


游戏最近收到的bugly崩溃日志如上:

这样的问题是由于服务器未注册却要卸载服务的问题导致的,查看源码,做如下修改就一切顺利了:

if (mHelper != null) mHelper.dispose();

        mHelper = null;

这段代码修改为

try {

           if (mHelper != null) mHelper.dispose();

           mHelper = null;

       }catch (IllegalArgumentException e){

           Log.d("TMA Billing Android 2.2","Error: "+e.getMessage());

           mHelper = null;

       }

添加一个try catch,

也可以在mHelper.dispose();中做修改

if (mServiceConn != null) {

        logDebug("Unbinding from service.");

            if( mContext != null)

            {

            logDebug("shixclog Unbinding mContext != null!");

            if (mService != null

                {

            logDebug("shixclog Unbinding mService != null!");

                mContext.unbindService(mServiceConn);

                }

                else

                {

                logDebug("shixclog Unbinding mService == null!");

                }

            }

            else

            {

            logDebug("shixclog Unbinding mContext == null!");

            }

            mServiceConn = null;

            mService = null;

            mPurchaseListener = null;

        }




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值