Recently my game started crashing while making a purchase. I've tried with billing library version 3 and 5. My targetSdkVersion is 32, billing version is 5.0.0, and play services version 4.3.14. I've tried playing with different versions, but I get the same weird bug. The purchase box comes up, everything looks fine, it fetches inapp details perfectly, after clicking the buy button, when the box disappears, after like 2 sec, when it gets to the consuming part, randomly it either works or shows crash box saying "Google Play store has stopped"(the game doesn't crash), and purchase fails. When I take a look at the logs, it looks like the billing service gets disconnected for no reason.
2022-10-18 20:03:06.310 6304-6304/idle.shopping.megastore W/BillingClient: Billing service disconnected.
2022-10-18 20:03:06.310 6304-6304/idle.shopping.megastore D/IAP_TAG: Setup finished.
2022-10-18 20:03:06.312 6304-6883/idle.shopping.megastore I/PlayCore: UID: [12124] PID: [6304] PrewarmService : reportBinderDeath
2022-10-18 20:03:06.312 6304-6883/idle.shopping.megastore I/PlayCore: UID: [12124] PID: [6304] PrewarmService : PrewarmService : Binder has died.
2022-10-18 20:03:06.316 6304-7267/idle.shopping.megastore W/BillingClient: Error consuming purchase!
android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:763)
at com.google.android.gms.internal.play_billing.zzh.zzp(com.android.billingclient:billing@@5.0.0:2)
at com.google.android.gms.internal.play_billing.zzc.zze(com.android.billingclient:billing@@5.0.0:6)
at com.android.billingclient.api.BillingClientImpl.zzl(com.android.billingclient:billing@@5.0.0:5)
at com.android.billingclient.api.zzu.call(Unknown Source:6)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
2022-10-18 20:03:06.317 6304-7267/idle.shopping.megastore D/IAP_TAG: Purchase wasn't consumed.
Here's another weird thing. After clicking buy button, when the purchase box shows processing/loading things.. if I click on anywhere on screen during that, it perfectly works. Like clicking outside the box while it's purchasing, and hiding the box, makes it work. If I don't click, it take a little longer for the game to resume(not too long, like 2 seconds), and I randomly get this crash/disconnecting thing. Any idea what to do?