Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In app billing (v3) - understanding a nullpointerexception

I have an app in which I have added in app billing (v3). The published app appeared to work fine of the (admittedly small number) of devices I tested. The code was obfuscated with proguard, but I kept corresponding proguard mapping.txt.

A few purchases were made successfully, but I have also got reports of crashes. I then used retrace.bat to translate the crash stack traces and got the following result:

java.lang.NullPointerException

at com.mycompany.mygame.util.IabHelper.void startSetup(com.mycompany.mygame.util.IabHelper$OnIabSetupFinishedListener)(Unknown Source)
                                      void dispose()
                                      void launchPurchaseFlow(android.app.Activity,java.lang.String,int,com.mycompany.mygame.util.IabHelper$OnIabPurchaseFinishedListener,java.lang.String)
                                      boolean handleActivityResult(int,int,android.content.Intent)
                                      com.mycompany.mygame.util.Inventory queryInventory$337baa91(boolean,java.util.List)
                                      void queryInventoryAsync$69bb631c(java.util.List,com.mycompany.mygame.util.IabHelper$QueryInventoryFinishedListener)
                                      java.lang.String getResponseDesc(int)
                                      int getResponseCodeFromBundle(android.os.Bundle)
                                      int queryPurchases(com.mycompany.mygame.util.Inventory,java.lang.String)
                                      int querySkuDetails(java.lang.String,com.mycompany.mygame.util.Inventory,java.util.List)
                                      void logDebug(java.lang.String)

at com.mycompany.mygame.util.IabHelper.void startSetup(com.mycompany.mygame.util.IabHelper$OnIabSetupFinishedListener)(Unknown Source)
                                      void dispose()
                                      void launchPurchaseFlow(android.app.Activity,java.lang.String,int,com.mycompany.mygame.util.IabHelper$OnIabPurchaseFinishedListener,java.lang.String)
                                      boolean handleActivityResult(int,int,android.content.Intent)
                                      com.mycompany.mygame.util.Inventory queryInventory$337baa91(boolean,java.util.List)
                                      void queryInventoryAsync$69bb631c(java.util.List,com.mycompany.mygame.util.IabHelper$QueryInventoryFinishedListener)
                                      java.lang.String getResponseDesc(int)
                                      int getResponseCodeFromBundle(android.os.Bundle)
                                      int queryPurchases(com.mycompany.mygame.util.Inventory,java.lang.String)
                                      int querySkuDetails(java.lang.String,com.mycompany.mygame.util.Inventory,java.util.List)
                                      void logDebug(java.lang.String)

at com.mycompany.mygame.util.IabHelper$2.void run()(Unknown Source)
at java.lang.Thread.run(Thread.java:1019)

I'm a bit hazy about how to read stack traces, but I'm guessing that perhaps there was a null pointer within OnIabPurchaseFinishedListener...? If so, how might that have happened?

EDIT: Does that fact that "launchPurchaseFlow" appears in the stack trace mean that the program crashed while the user was trying to purchase something?

EDIT: As requested here's the listener:

/**
 * Callback that notifies when a purchase is finished.
 */
public interface OnIabPurchaseFinishedListener {
    /**
     * Called to notify that an in-app purchase finished. If the purchase was successful,
     * then the sku parameter specifies which item was purchased. If the purchase failed,
     * the sku and extraData parameters may or may not be null, depending on how far the purchase
     * process went.
     *
     * @param result The result of the purchase.
     * @param info The purchase information (null if purchase failed)
     */
    public void onIabPurchaseFinished(IabResult result, Purchase info);
}
like image 891
Mick Avatar asked Mar 14 '13 18:03

Mick


1 Answers

Maybe this relates to the issue raised here: https://code.google.com/p/android/issues/detail?id=42338

The updated code hasn't been pushed out to the SDK Manager yet, but you can view all the changes related to this issue here: https://code.google.com/p/marketbilling/source/detail?r=7ec85a9b619fc5f85023bc8125e7e6b1ab4dd69f

There are 4 files affected by the issue. Make the changes they suggest and see if you still run into the same issue.

like image 130
joelreeves Avatar answered Oct 04 '22 02:10

joelreeves