IabHelper crashes 整理

IabHelper crashes

1. Android in-app billing: onServiceConnected is never called and bindService returns “false”

Install your application on an Android-powered device.

You cannot use the emulator to test In-app Billing; you must install your application on a device to test In-app Billing.

https://stackoverflow.com/questions/39720891/android-in-app-billing-onserviceconnected-is-never-called-and-bindservice-retur

2.queryPurchases java.lang.NullPointerException

at com.myapp.util.IabHelper.queryPurchases(SourceFile:836)

https://stackoverflow.com/questions/15456434/billing-api-v3-iabhelper-nullpointerexception

change

 if (querySkuDetails) {
            r = querySkuDetails(ITEM_TYPE_INAPP, inv, moreItemSkus);
            if (r != BILLING_RESPONSE_RESULT_OK) {
                throw new IabException(r, "Error refreshing inventory (querying prices of items).");
            }
        }

to

if (querySkuDetails) {
         try {
                r = querySkuDetails(ITEM_TYPE_INAPP, inv, moreItemSkus);
                if (r != BILLING_RESPONSE_RESULT_OK) {
                    throw new IabException(r, "Error refreshing inventory (querying prices of items).");
                }
            } catch (NullPointerException e) {
                throw new IabException(IABHELPER_UNKNOWN_ERROR, "NPE while refreshing inventory.", e);
            }
        }

change

if (querySkuDetails) {
                r = querySkuDetails(ITEM_TYPE_SUBS, inv, moreSubsSkus);
                if (r != BILLING_RESPONSE_RESULT_OK) {
                    throw new IabException(r, "Error refreshing inventory (querying prices of subscriptions).");
                }
            }

to

if (querySkuDetails) {
                try {
                    r = querySkuDetails(ITEM_TYPE_SUBS, inv, moreSubsSkus);
                    if (r != BILLING_RESPONSE_RESULT_OK) {
                        throw new IabException(r, "Error refreshing inventory (querying prices of subscriptions).");
                    }
                } catch (NullPointerException e) {
                    throw new IabException(IABHELPER_UNKNOWN_ERROR, "NPE while refreshing inventory.", e);
                }
            }

3.IabHelper.startSetup (IabHelper.java:267) NullPointerException

https://stackoverflow.com/questions/20763952/iabhelper-startsetup-causes-nullpointerexception

change

List<ResolveInfo> queryIntentServices = mContext.getPackageManager().queryIntentServices(serviceIntent, 0);
if (queryIntentServices != null && !queryIntentServices.isEmpty()) {
        // service available to handle that Intent
        mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章