android-inapp-billing-v3
android-inapp-billing-v3 copied to clipboard
NPE in isOneTimePurchaseSupported method
I am getting this error for some of the purchases,
lang.java.NullPointerException: (Attempt to invoke interface method 'int com.android.vending.billing.IInAppBillingService.isBillingSupported(int, java.lang.String, java.lang.String)' on a null object reference) at v3.iab.android.anjlab.com.BillingProcessor.isOneTimePurchaseSupported(BillingProcessor.java:242)
It seems to occur when the isOneTimePurchaseSupported method is called on the BillingProcessor. It is worth noting that it does not occur for every purchase - some of the purchases are successful I am using 1.0.38 version of this library.
@kal27 seem like we need to add a check for isInitialized() at the beginning of this method. Do you want to contribute with a PR?
To solve this issue for myself, I put the check for isOneTimePurchaseSupported in the onBillingInitialized method, like so:
@Override
public void onBillingInitialized() {
/*
* Called when BillingProcessor was initialized and it's ready to purchase
*/
isOneTimePurchaseSupported = billingProcessor.isOneTimePurchaseSupported();
}
This ensures the billingProcessor object was initialized and is not null.
@DesigningKnights I am using something like that, and that's exactly what's causing the issue, as isOneTimePurchaseSupported() calls isBillingSupported(), and the NPE happens then in isBillingSupported().
Fatal Exception: java.lang.NullPointerException
Attempt to invoke interface method 'int com.android.vending.billing.IInAppBillingService.isBillingSupported(int, java.lang.String, java.lang.String)' on a null object reference
com.anjlab.android.iab.v3.BillingProcessor.isOneTimePurchaseSupported (SourceFile:394)
org.faked.isms2droid.MainActivity$1.onBillingInitialized (SourceFile:324)
...
I have the same bug - according to google play prelauch.
I think this is more or less the same as #302. Still having this problem too.
Submitted PR, it passed tests, looking forwards for review
@serggl Will there be a new release any time soon? I squashed all bugs in my app, except for this one...
@jangrewe if you refer to #376 -I would recommend you to link your project with a master branch of this repo.
I'm not sure what you mean with "link your project with a master branch of this repo"? I'm using the library via Maven, so i guess unless there's a snapshot of the master branch in the Maven repo, i'd have to build it myself? That's something i'd rather not do! ;-)