I'm getting notified that my Billing solution is crashing in a weird way. I'm unable to reproduce it or find a fix/bypass the problem. Maybe you could help.
Fatal Exception: java.lang.IllegalStateException: Already resumed
at kotlin.coroutines.SafeContinuation.resumeWith + 45(SafeContinuation.java:45)
at com.android.billingclient.api.BillingClientKotlinKt$querySkuDetails$2$1.onSkuDetailsResponse + 2(BillingClientKotlinKt.java:2)
at com.android.billingclient.api.zzj.run + 8(zzj.java:8)
at android.os.Handler.handleCallback + 907(Handler.java:907)
at android.os.Handler.dispatchMessage + 105(Handler.java:105)
at android.os.Looper.loop + 216(Looper.java:216)
at android.app.ActivityThread.main + 7625(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 524(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main + 987(ZygoteInit.java:987)
//billing
implementation 'com.android.billingclient:billing:2.2.0'
implementation 'com.android.billingclient:billing-ktx:2.1.0'
Since last week we have this code running to prevent the exception:
suspend fun BillingClient.querySkuDetailsFixed(params: SkuDetailsParams) = suspendCancellableCoroutine<SkuDetailsResult> { continuation ->
querySkuDetailsAsync(params) { billingResult, skuDetails: List<SkuDetails>? ->
if (continuation.isActive) {
// doing some logging
continuation.resumeWith(Result.success(SkuDetailsResult(billingResult, skuDetails)))
} else {
// Already resumed, doing some logging
}
}
}
In the logs we see that we get 2 calls from the library:
The first response has always the BillingResponseCode -3 SERVICE_TIMEOUT
.
The second response often has either 6 ERROR
or 2 SERVICE_UNAVAILABLE
.
In our case this is happening when the app is awaken in the background for a PeriodicWorkRequest
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With