cordova-plugin-inapppurchase icon indicating copy to clipboard operation
cordova-plugin-inapppurchase copied to clipboard

Dozens of NullPointerException Errors every day

Open Marcophono2 opened this issue 7 years ago • 21 comments

Hello! My Cordova app (including Crosswalk plugin) is live in the Google Store. I changed out the IAB plugin a few weeks ago due to too many errors in the purchase process. But this plugin seems to have the same or similar problems. Every day I find in the ANRS&crashes section of my developer account dozens of crash reports every day. The same errors were reported here some times in the past but never got a response. I am really wondering how the most important plugin a Cordova app can have - finally being paid for the hard work of creating an app via the IAB plugin - can still contain so serious bugs which were completely ignored. Anyway, for me it is essential to fix this issue. Of course I'll pay for that job. Is there someone interested? I hope I do not touch any board rules here asking for a programmer.. I cannot test it out on my own device. I never catch an error. Here are some of the catched errors from my Google developer account:

Samsung Galaxy Xcover3 (xcover3lte), 1536MB RAM, Android 5.1 java.lang.NullPointerException: at com.alexdisler.inapppurchases.IabHelper.queryPurchases (IabHelper.java:849) at com.alexdisler.inapppurchases.IabHelper.queryInventory (IabHelper.java:571) at com.alexdisler.inapppurchases.IabHelper.queryInventory (IabHelper.java:535) at com.alexdisler.inapppurchases.IabHelper$2.run (IabHelper.java:630) at java.lang.Thread.run (Thread.java:818)

Samsung Galaxy S5 mini (kminilte), 1536MB RAM, Android 6.0 java.lang.NullPointerException: at com.alexdisler.inapppurchases.IabHelper.queryPurchases (IabHelper.java:849) at com.alexdisler.inapppurchases.IabHelper.queryInventory (IabHelper.java:571) at com.alexdisler.inapppurchases.IabHelper.queryInventory (IabHelper.java:535) at com.alexdisler.inapppurchases.IabHelper$2.run (IabHelper.java:630) at java.lang.Thread.run (Thread.java:818)

Samsung Galaxy S7 (herolte), 4096MB RAM, Android 7.0 java.lang.NullPointerException: at com.alexdisler.inapppurchases.IabHelper.queryPurchases (IabHelper.java:849) at com.alexdisler.inapppurchases.IabHelper.queryInventory (IabHelper.java:571) at com.alexdisler.inapppurchases.IabHelper.queryInventory (IabHelper.java:535) at com.alexdisler.inapppurchases.IabHelper$2.run (IabHelper.java:630) at java.lang.Thread.run (Thread.java:762)

[...]

Best regards Marc

Marcophono2 avatar Aug 21 '17 22:08 Marcophono2

Hi there,

this is a much bigger issue than what you're describing here. There are dozens of people having these problems, as it's not a problem with this inapppurchase library, but with the Google IabHelper (which has been developed by Google).

Just look into this Stackoverflow Question to see that there's a lot of complaining going on.

Currently I'm experimenting with InAppBillingV6 maybe I'll update it here too, once I've done enough testing. Would you be interested to test it too?

Regarding the asking for a programmer, it's not a problem at all, you may also openly post a bounty on BountySource so others can also look into this if you like.

Cheers Moritz

moritzgloeckl avatar Aug 22 '17 07:08 moritzgloeckl

Thank you, Moritz! I wasn't sure if I'll receive such a nice answer due to my angry expressed post but you made my day! Yes, I am happy if I can help you testing your code. I have 100,000 active app users. THEY will test it for you. Aside from that: Is there no other way to use an IAB plugin for Cordova which is not basing on that buggy Google code from 2012? Also I wrote an email to Trevor Johns, the developer of that java code asking him if he really things that the bugs are all fixed. He is not responsible for anything but should tell the truth if someone asks him. An IAB plugin is not a nice to have plugin. It is essential for surviving for indie developers who code in Cordova.

Best regards from Dortmund ;-) Marc

Marcophono2 avatar Aug 22 '17 13:08 Marcophono2

Hi Moritz! Good news! Trevor answered my email. He was surprised about the dimensions of the buggy IabHelper.java and offered to fix the code. He asked for a link to get a good overview of all symptomics. Can you provide me with such a link? I also know a lot of threads but Idon't have the overview which posted issues on different threads are basing on the same bug and also I think most of each posted issues are not complete. May be you know where a good issue tracker or thread to find regarding the IabHelper trouble?

Best regards Marc

Marcophono2 avatar Aug 23 '17 11:08 Marcophono2

Hi Marc!

Nice! It would be cool to have someone look over the code. I don't have a link of all symptoms unfortunately other than the issues posted here. There's another plugin for cordova in app purchases I'll see if they do it better than we are currently.

If you find out anything I'm very happy to work together to fix these issues.

Thank you very much and kind regards from Austria ;-)

Moritz

moritzgloeckl avatar Aug 24 '17 13:08 moritzgloeckl

I get the same errors reported in my crash reporting tool from time to time (affects less than 1% of total users, most of are not buyers though).

nilebma avatar Aug 25 '17 12:08 nilebma

@nilebma @Marcophono2

I've created a testing branch, I'll implement the fix suggest on the Stackoverflow Question I linked above,

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.

could you two guys test it please and keep us updated here if you notice anything?

moritzgloeckl avatar Aug 25 '17 12:08 moritzgloeckl

Noticing this issue as well, anyone have any quick work arounds?

fierysolid avatar Sep 07 '17 18:09 fierysolid

Hey guys, So I was just doing some research about picking a plugin for inAppPurchases and checked out the one from j3k0 and this one too. I looked out issues and got curious about this one. It seems like those guys have already patched the iabHelper.java https://github.com/j3k0/cordova-plugin-purchase/commit/429fcdb616a94784f79280bc916cc655eb8bdeda#diff-75186e7bea31c3bcec3cb64c72545e18 So I assume you can simply catch that exception too and this should solve the problem. However, both plugins use IABHelper which is absolutely old and deprecated :( I wish if there was plan to upgrade to newer iab client from android sdk.

bshafiee avatar Oct 13 '17 22:10 bshafiee

@bshafiee If you like you can send us a PR!

moritzgloeckl avatar Oct 14 '17 11:10 moritzgloeckl

I am seeing the same error message from my Google developer account. Is the comment from RainerAppel posted on Sep 5 considered a workaround? Or what is the best way to fix this? Thank you.

FiveHundredMiles avatar Oct 28 '17 10:10 FiveHundredMiles

I see the same error in the Google Play Console:

java.lang.NullPointerException com.alexdisler.inapppurchases.IabHelper.queryPurchases at com.alexdisler.inapppurchases.IabHelper.queryPurchases (IabHelper.java:849) at com.alexdisler.inapppurchases.IabHelper.queryInventory (IabHelper.java:571) at com.alexdisler.inapppurchases.IabHelper.queryInventory (IabHelper.java:535) at com.alexdisler.inapppurchases.IabHelper$2.run (IabHelper.java:630) at java.lang.Thread.run (Thread.java:818)

@Marcophono2 @moritzgloeckl @nilebma @RainerAppel @fierysolid @bshafiee @FiveHundredMiles how did you solved it? Thank you very much!

sbat avatar Nov 25 '17 07:11 sbat

I deleted my comment posted on Sep 5 because this did not work.

Currently I still have no solution for this. I tried with a patched version of IabHelper.java but no success so far.

Note: You can't just patch plugins/cordova-plugin-inapppurchase/src/android/IabHelper.java because cordova seems to replace it with the original on every build.

RainerAppel avatar Jan 05 '18 06:01 RainerAppel

Any news about this issue? We should resolve this. Since Google uses the number of errors to rank the apps, this problem might give us a bad rank position, that implies less users, and thus, less revenue.

oangelo avatar Jan 12 '18 14:01 oangelo

I think I have finallly fixed this issue. Catching all those NullPointerExceptions at least avoids the crashes. Here ist the pull request: https://github.com/AlexDisler/cordova-plugin-inapppurchase/pull/208

RainerAppel avatar Feb 10 '18 22:02 RainerAppel

Guys, please add a message here, when you merge this PR. Having the same issue. Thanks!

gpaslari avatar Feb 19 '18 03:02 gpaslari

Will these exceptions get avoided in this repo ?

Risingson avatar May 23 '18 13:05 Risingson

I'm algo facing the same problem. Dozens of crash everyday.

screen shot 2018-08-27 at 4 17 13 pm screen shot 2018-08-27 at 4 17 28 pm

ibnclaudius avatar Aug 27 '18 19:08 ibnclaudius

So throwing the error appears to mean that it just fixes the crash reporting, but failed purchases still occur because the source issue (objects being dumped from memory) is still happening.

Am I correct in believing that throwing the exception still means purchases will fail? I have been unable to replicate the issue so cannot confirm/deny the latter question. If that is the case, how does one ensure that the objects don't get dumped and if they do they get reinitialized?

heavengames avatar Feb 06 '19 18:02 heavengames

We too get this error quite frequently and a lot of complains from the users that the app crashes.

Since I can't reproduce it, has anyone tried the bugfix from ghenry22 and can confirm that the error is not just "caught" but also the purchase works?!

Thank you!

francois-dibulo avatar Jun 17 '19 08:06 francois-dibulo

Switch to react-native and never look back haha

fierysolid avatar Jun 17 '19 10:06 fierysolid

@francois-n-dream, I can confirm that the pull request from @RainerAppel works, the error is "caught" and the purchase works. BUT, it is better to update to Ionic 4 as soon as possible.

oangelo avatar Jun 17 '19 13:06 oangelo