Bug Issue: IInAppBillingService - Crash reported in Google Plays pre-launch report


Pages: 1

svintaj

  • Level 3 Stencyler
March 12, 2019, 05:42:38 am
I don't have this crash myself, but this crash is reported in Google Plays pre-launch report:
Quote
Problem: java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.android.vending.billing.IInAppBillingService.getPurchases(int, java.lang.String, java.lang.String, java.lang.String)' on a null object reference
Code: [Select]
java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.android.vending.billing.IInAppBillingService.getPurchases(int, java.lang.String, java.lang.String, java.lang.String)' on a null object reference
at com.stencyl.android.util.IabHelper.queryPurchases(IabHelper.java:945)
at com.stencyl.android.util.IabHelper.queryInventory(IabHelper.java:624)
at com.stencyl.android.util.IabHelper$2.run(IabHelper.java:698)
at java.lang.Thread.run(Thread.java:764)
This happens in the start of the game and the only thing related to purchases there is this code block:

And this code block:

And also this code block:


I say that should be safe. So what could cause the crash? :-\
I am using Stencyl 4.0.1 (Official)


rob1221

  • Master Stencyler
  • *
March 12, 2019, 06:49:55 am
It looks like either the billing service didn't start or the service was disconnected, since the variable for the service (mService) is the thing that is null here.


svintaj

  • Level 3 Stencyler
March 12, 2019, 08:28:31 am
Is there any way I can test if the 'billing service' has started with code in Stencyl?
I guess it's not always safe to run ---> purchasesAreInitialized()  <---    Could that potentially cause a crash, if the 'billing service' for some reason not has started?  ( The method for the 'if player can make purchases' bool )


rob1221

  • Master Stencyler
  • *
March 12, 2019, 11:17:06 am
It looks like the crash point can't be reached if the service hasn't started yet.  Assuming that is true, I see only two points where mService is set to null.  The first is the onServiceDisconnected callback.  I'm not sure what circumstances that would be called in but if it's called as part of Google's testing then that could be the problem as it doesn't prevent you from trying to use purchase blocks.  The second point is the dispose function which is handled on Stencyl's end, and I'm not sure when that is triggered.


svintaj

  • Level 3 Stencyler
March 14, 2019, 07:53:40 am
A related sidenote: It seems like  the 'if player can make purchases' bool is always false on iOS. So I had to take away the 'if player can make purchases' bool on iOS, to have the iOS version working. 

So purchasesAreInitialized() is not consistent on both Android and iOS, that may be good to know.


Raiyumi

  • Subscriber - Stencyl Studio
  • *
April 15, 2019, 11:11:13 am
Been getting the same errors which was raising my android crash rate. Although I won't be able to test since I can't replicate it on my device.
Code: [Select]
java.lang.NullPointerException:
  at com.stencyl.android.util.IabHelper.queryPurchases (IabHelper.java:945)
  at com.stencyl.android.util.IabHelper.queryInventory (IabHelper.java:624)
  at com.stencyl.android.util.IabHelper$2.run (IabHelper.java:698)
  at java.lang.Thread.run (Thread.java:764)
Curious if any found a fix.


Justin

  • Master Stencyler
  • *
June 29, 2019, 04:22:43 am
https://github.com/googlesamples/android-play-billing/issues/45

According to some comments there, it's just something that happens sometimes due to background operations performed by the Play Store App.

I've included some code to detect this issue (b10406), and it should prevent it from crashing at least, but will still cause any purchasing to fail.


Justin

  • Master Stencyler
  • *
August 09, 2021, 02:13:11 pm
Since I never heard about this again, I guess the fix I applied back then worked to prevent crashing.

Purchases has been reimplemented in Stencyl 4.1.0 using Googe Play Billing v4, so this issue doesn't apply anymore.
  • Status changed from New to Closed


Pages: 1

Details

  • Reported
    March 12, 2019, 05:42:38 am
  • Updated
    August 09, 2021, 02:13:11 pm

  • View Status
    Public
  • Type
    Bug
  • Status
    Closed
  • Priority
    Normal
  • Version
    3.5.0 beta 1
  • Fixed in
    (none)
  • Assigned to
    (none)
  • Category
    Engine

Tags