Google Play billing library returns empty purchases list for two Google accounts on device

I’m using Google Play Billing Library and I have problem to get purchases, when the user uses two or more Google accounts in the device.

To get purchases using: billingClient.queryPurchases(BillingClient.SkuType.INAPP) and
everything is working fine, when user has only one Google account in the device. If there is more than one Google account, queryPurchases (sometimes, see below) returns empty list.

Let’s say:
User U1 has purchase P.
User U2 has no purchases.
No one is logged in to the device.

Steps:

  • Add U2 as a first account on the device. queryPurchases returns empty list. It’s correct.
  • Add U1 as a second account on the device. queryPurchases returns empty list. It’s NOT correct.

If steps are in reverse order (U1 as a first account and U2 as a second account), everything is OK.
So it probably depends on the order of add account to the device?

The same problem occurs when:
(no one is logged in to the device)

  • User U1 is added to the device as a first account. queryPurchases returns purchase P. It’s correct.
  • User U2 is added to the device as a second account. queryPurchases returns purchase P. It’s correct.
  • Logout U1, Login U1 and queryPurchases returns empty list. It’s NOT correct.

Source: Android Questions

LEAVE A COMMENT