Android: iap.restore(), iap.finish() and iap.buy() in sequence

Hello!

In my game I have a situation when I need to restore() item, then finish() it, then buy() and so on.
It looks like the case isn’t implemented yet because after reloading the app I have strange behaviour like loosing ability to restore item or to buy it or I catch an exception.

Here is a stack trace of the exception:

01-21 20:00:33.975 19469 19469 E AndroidRuntime: FATAL EXCEPTION: main
01-21 20:00:33.975 19469 19469 E AndroidRuntime: Process: ..., PID: 19469
01-21 20:00:33.975 19469 19469 E AndroidRuntime: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
01-21 20:00:33.975 19469 19469 E AndroidRuntime: at java.util.ArrayList.get(ArrayList.java:437)
01-21 20:00:33.975 19469 19469 E AndroidRuntime: at com.defold.iap.IapGooglePlay$5.onSkuDetailsResponse(IapGooglePlay.java:343)
01-21 20:00:33.975 19469 19469 E AndroidRuntime: at com.defold.iap.IapGooglePlay$6.onSkuDetailsResponse(IapGooglePlay.java:376)
01-21 20:00:33.975 19469 19469 E AndroidRuntime: at com.android.billingclient.api.zzj.run(com.android.billingclient:billing@@3.0.0:8)
01-21 20:00:33.975 19469 19469 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:873)
01-21 20:00:33.975 19469 19469 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
01-21 20:00:33.975 19469 19469 E AndroidRuntime: at android.os.Looper.loop(Looper.java:201)
01-21 20:00:33.975 19469 19469 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6864)
01-21 20:00:33.975 19469 19469 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
01-21 20:00:33.975 19469 19469 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
01-21 20:00:33.975 19469 19469 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

I’m using Defold version 1.2.178

I saw few posts about iap.restore() on Android and as I understood it’s not supported to call iap.buy() after iap.restore(), isn’t it?

How can I do it?

Thanks

Thanks for reporting. It definitely shouldn’t crash. Are you using the latest version of the extension?

Can you please report the issue including detailed steps to reproduce here:

Bug reported:
https://forum.defold.com/t/android-iap-restore-iap-finish-and-iap-buy-in-sequence/67358