ANR: com.android.billingclient:billing@@4.0.0

Hello!

I have a problem with ANR error:

From Google Play Dev Console.
com.android.billingclient:billing@@4.0.0 - com.android.billingclient.api.zzaf.zzdInput dispatching timed out

If I remove the IAP package from the project, the error disappears.

Unity 2021.3.17f
IAP 4.5.2
All packages in attach.
Logs in attach.

8784325–1193005–log.txt (21.8 KB)

Hello BOLDCAT,

Could you provide the steps you are using to reproduce this error?
Are you using coded or codeless IAP? Could you share your implementation?
If you had a working version of IAP before 4.5.2, which version was it?

What device is this happening on? Have you tried others?

We have an ANR fix coming up in IAP 4.6.0 that can happen while pausing/unpausing, could this be your case?

Hello!

  1. I’m using coded IAP (in attach)
  2. Before I was using the old version 4.4.1
  3. About devices. I look at the list in the Google play console (a lot of low-end devices with different OS version)

8786743–1193563–Purchaser.cs (7.99 KB)

Thank you for the answers, here’s a few more question:

  • The code seems good. as long as the initialization doesn’t fail (it’s not recommended to initialize IAP more than once).
    In your case, does the initialization succeed or fail when you get this problem?

  • If you try 4.4.1 again, does it work or same problem?

  • Could you obtain the device log instead of the Google Play Console? Or is there more logs available?

  • Do you know the specific devices and OS versions that have the error?

So far nothing seems wrong on the IAP side and the logs don’t have any information pointing to either BillingClient or Unity IAP, so I will need more information on the problem or steps to reproduce.

Hello!

  1. The problem is not with me, but with the users of my project. ANR rate with this error 2% of users, which for Google is very critical.
  2. Google no longer allows you to upload builds with this version. But I had this version before and there were no such errors.
  3. I can’t get the device logs. Only Google play logs. I have attached more logs from the google console, maybe they will help.
  4. Attached.

8789314–1194085–log_1.txt (19.8 KB)
8789314–1194088–log_2.txt (18.1 KB)


The logs don’t have much information regarding IAP other than the BillingClient lines which makes it hard to say what the problem is. It seems there’s a callback from the Google Billing Client being blocked on the main thread.
There’s a limitation of the Billing Client where some of its methods are only invoked on the main thread:
https://developer.android.com/reference/com/android/billingclient/api/BillingClient
Is it possible that while IAP is being initialized or a purchase is being made, there could be something else blocking the main thread?

Also, what version of Unity Services Core are you using? Updating to 1.7.0 might also help.

We also have 4.6.0 coming out soon that fixes an ANR, so this might solve your issue!

Hi, we are using unity purchasing 4.6.0 and are facing some ANR related to
com.android.billingclient:billing@@4.0.0, but we are not sure if this is the same problem as this thread. Log is in the attachment file. Thanks for the support.

8862795–1209429–log.txt (1.48 KB)

Hello leochien,
Thank you for the report, this one related to BillingClientStateListener.onBillingServiceDisconnected() is fixed for 4.7.0 coming out soon.

@Yannick_D Will 4.7.0 be available today as expected? I will postpone the next release if it will be available today.

Hello domonyiv,

IAP 4.7.0 is still coming out today! There should be an announcement soon along with the release.

1 Like

Hello!
Unity 2021.3.17 + IAP 4.7.0
The error did not go away



Hello BOLDCAT,

In one of your screenshots, it says that the main thread is blocked and is trying to acquire a lock held by thread 116.
Does your logs have the stack trace from that thread? If yes, could you provide it?

Also, in our next release 4.8.0, we are upgrading to Google Billing v5 (minimal upgrade, no new features) which might fix this issue since it started with Google Billing v4.

Hello!
I apologise for the long reply, been busy with other tasks. It’s been a long time, the project is already on a different version of Unity and a new version of IAP. But the error still persists. Now it is with the new version.

UNITY 2021.3.30f + IAP 4.9.4

ANR
com.android.billingclient:billing@@5.2.1 - com.android.billingclient.api.zzap.zzdInput dispatching timed out

There’s a Google tip. But I don’t understand what kind of blocking tread they’re talking about? How to track it?

9360560–1309088–stacktrace.txt (21.1 KB)
9360560--1309094--Снимок экрана 2023-09-23 в 17.51.42.png

I’m having the same problem. I also wrote about a similar issue in another thread, but didn’t get a reply from Unity. If anyone knows if this is a Google issue or not, please reply.