Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – SecurityException:使用应用内结算将Binder调用到错误的界面大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在尝试使用Google提供的应用内结算库时遇到了SecurityException.以下是完整的例外情况:
07-05 15:56:47.783  26481-26481/com.andrewq.planets E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.andrewq.planets,PID: 26481
    java.lang.SecurityException: Binder invocation to an incorrect interface
            at android.os.Parcel.readException(Parcel.java:1465)
            at android.os.Parcel.readException(Parcel.java:1419)
            at billing.IInAppBillingservice$stub$Proxy.isBillingSupported(IInAppBillingservice.java:208)
            at com.android.vending.billing.IabHelper$1.onserviceConnected(IabHelper.java:227)
            at android.app.LoadedApk$serviceDispatcher.doConnected(LoadedApk.java:1101)
            at android.app.LoadedApk$serviceDispatcher$RunConnection.run(LoadedApk.java:1118)
            at android.os.Handler.handleCallBACk(Handler.java:733)
            at android.os.Handler.dispatch@R_944_8798@ge(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)

这是带有第227行的IabHelper.java方法

@Override
    public void onserviceConnected(ComponentName name,IBinder servicE) {
        if (mDisposed) return;
        logDebug("Billing service connected.");
        mservice = IInAppBillingservice.stub.asInterface(servicE);
        String packagename = mContext.getPackagename();
        try {
            logDebug("checking for in-app billing 3 support.");

            // check for in-app billing v3 support
            //**LINE 227**
            int response = mservice.isBillingSupported(3,packagename,ITEM_TYPE_INAPp);
            if (response != BILLING_RESPONSE_RESULT_OK) {
                if (listener != null) listener.onIabSetupFinished(new IabResult(response,"Error checking for billing v3 support."));

                // if in-app purchases aren't supported,neither are subscriptions.
                mSubscriptionsSupported = false;
                return; 
            }
            logDebug("in-app billing version 3 supported for " + packageName);

            // check for v3 subscriptions support
            response = mservice.isBillingSupported(3,ITEM_TYPE_SUBS);
            if (response == BILLING_RESPONSE_RESULT_OK) {
                logDebug("Subscriptions AVAILABLE.");
                mSubscriptionsSupported = true;
            } else {
                logDebug("Subscriptions NOT AVAILABLE. Response: " + responsE);
            }

            mSetupDone = true;
        } catch (remoteexception E) {
            if (listener != null) {
                listener.onIabSetupFinished(new IabResult(IABHelPER_REMOTE_EXCEPTION,"remoteexception while setTing up in-app billing."));
            }
            e.printStackTrace();
            return;
        }

        if (listener != null) {
            listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_OK,"Setup successful."));
        }
    }
};

最后,这是IInAppBillingservice.java文件,其中第208行是:

@Override public int isBillingSupported(int apiVersion,java.lang.String packagename,java.lang.String typE) throws android.os.remoteexception
{
    android.os.Parcel _data = android.os.Parcel.obtain();
    android.os.Parcel _reply = android.os.Parcel.obtain();
    int _result;
    try {
        _data.writeInterfaCEToken(DESCRIPTOR);
        _data.writeInt(apiVersion);
        _data.writeString(packageName);
        _data.writeString(typE);
        mRemote.transact(stub.transaCTION_isBillingSupported,_data,_reply,0);
        //**LINE 208**
        _reply.readException();
        _result = _reply.readInt();
    }
    finally {
        _reply.recycle();
        _data.recycle();
    }
    return _result;
}

现在,当我第一次启动我的应用程序时会发生将调试器附加到进程后,我得到了异常.

解决方法

找到我的答案( here),希望它能解决你的问题. (它是中文的,但Chrome翻译了它.) 它与客户端的.AIDL位置有关.它必须与服务器中的.AIDL文件完全相同.它必须放在客户端的src文件夹中的同名包中.

大佬总结

以上是大佬教程为你收集整理的android – SecurityException:使用应用内结算将Binder调用到错误的界面全部内容,希望文章能够帮你解决android – SecurityException:使用应用内结算将Binder调用到错误的界面所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。