lundi 26 juin 2017

Purchase.getsku() returning null?

All I want to do is check if the user's purchase matches the SKU of "donate_one_dollar". However I get the error:

    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String util.Purchase.getSku()' on a null object reference

at com.curlybrace.ruchir.rescuer.MainActivity$13.onIabPurchaseFinished(MainActivity.java:1113)
at util.IabHelper.launchPurchaseFlow(IabHelper.java:472)
at util.IabHelper.launchPurchaseFlow(IabHelper.java:398)
at util.IabHelper.launchPurchaseFlow(IabHelper.java:392)

Basically, mPurchaseFinishedListener seems to be returning a null purchase object. How can I fix this?


IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
            = new IabHelper.OnIabPurchaseFinishedListener() {
        public void onIabPurchaseFinished(IabResult result, Purchase purchase) {

            Log.v("myTag", "Purchase finished. SKU = " +purchase.getSku()); //NOT WORKING

                if (purchase.getSku().equals("donate_one_dollar")) { **//DOESNT WORK**

                    Toast.makeText(MainActivity.this, "One dollar donated!", Toast.LENGTH_SHORT).show();
                }
        }
    };

I am using Beta testing with a testing account to test my purchases.

Aucun commentaire:

Enregistrer un commentaire