Billing API v3 IabHelper NullPointerException

后端 未结 6 787
萌比男神i
萌比男神i 2020-12-12 16:14

edit 4/15: Catching nullpointer in IabHelper appears to have stopped this problem. I am no longer seeing the exceptions being thrown, I\'m going to accept

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 16:32

    edit 4/15: Catching nullpointer in IabHelper appears to have stopped this problem. I am no longer seeing the exceptions being thrown, I'm going to accept this as an answer.


    edit 4/04: A little bit of a deeper dive. There are try catch blocks that handle RemoteExceptions and JSONExceptions for the queryPurchases method, but no NullPointerException handling. What I am going to try is include NullPointer Exception handling so IabHelper looks like this when trying to querySkuDetails:

        catch (NullPointerException e) {
            throw new IabException(IABHELPER_UNKNOWN_ERROR, "NullPointer while refreshing inventory.", e);
        }
    

    I just filed a bug on this:

    https://code.google.com/p/marketbilling/issues/detail?id=114


    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);
                    }
                }
    

提交回复
热议问题