Android : App crash while receiving iap.TRANS_STATE_PURCHASED state on IAP extension

Hello, I test the IAP transaction on my ‘Throwing Spear’ Game, and the game suddenly crashes when receive iap.TRANS_STATE_PURCHASED state.

Steps to reproduce the behavior:

  1. Disable auto-finish-transaction on game.project
  2. Buy a consumable item & choose the “Slow test card, approves after a few minutes” option
  3. Quit the app, after that open app again
  4. Wait for a few minutes to receive iap.TRANS_STATE_PURCHASED state
  5. App crash while receiving iap.TRANS_STATE_PURCHASED state

Defold version :

  • Version 1.4.1

Platforms :

  • Platforms: Android
  • OS: Android 13
  • Device: Samsung A32

Logs :

01-26 20:14:45.066 28683 28683 E AndroidRuntime: FATAL EXCEPTION: main
01-26 20:14:45.066 28683 28683 E AndroidRuntime: Process: com.throwingspear, PID: 28683
01-26 20:14:45.066 28683 28683 E AndroidRuntime: java.lang.RuntimeException: Error receiving broadcast Intent { act=com.android.vending.billing.PURCHASES_UPDATED flg=0x10 pkg=com.throwingspear (has extras) } in com.android.billingclient.api.zzn@63d92f5
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$android-app-LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1928)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at android.app.LoadedApk$ReceiverDispatcher$Args$$ExternalSyntheticLambda0.run(Unknown Source:2)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at android.os.Handler.handleCallback(Handler.java:942)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:99)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at android.os.Looper.loopOnce(Looper.java:226)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:313)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:8741)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
01-26 20:14:45.066 28683 28683 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void com.defold.iap.IPurchaseListener.onPurchaseResult(int, java.lang.String)' on a null object reference
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at com.defold.iap.IapGooglePlay.handlePurchase(IapGooglePlay.java:356)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at com.defold.iap.IapGooglePlay.onPurchasesUpdated(IapGooglePlay.java:367)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at com.android.billingclient.api.zzn.onReceive(com.android.billingclient:billing@@5.0.0:5)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$android-app-LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1918)
01-26 20:14:45.066 28683 28683 E AndroidRuntime:        ... 9 more

Can you please create a ticket on GitHub in the extension-iap repository?

2 Likes