In-app purchase fails in Google Play with a purchase error while testing
An error message in the Google Play purchase cartShort answer
A generic purchase error is the Play Store's way of saying the billing flow stopped. Log the BillingResult response code and debug message first. In test setups the cause is usually that the account is not a license tester, the product is not active or available in the tester's country, or the Play Store is out of date.
Fix it fast
1Find out which cause you have
Print the response code and debug message that launchBillingFlow or queryProductDetailsAsync returns. The code tells you which cause below applies, and the message often names the exact problem.
Log.e("Billing", "code=${billingResult.responseCode} msg=${billingResult.debugMessage}")2Match what you see, then jump to its fix
- 1
No test notice across the middle of the purchase dialog, and no test payment methods offeredThe account on the device is not a license testerFix - 2
BillingResponseCode.ITEM_UNAVAILABLE, or an empty product list from queryProductDetailsAsyncThe product is not available to this user (ITEM_UNAVAILABLE)Fix - 3
BillingResponseCode.BILLING_UNAVAILABLEThe Play Store cannot sell to this user right now (BILLING_UNAVAILABLE)Fix - 4
BillingResponseCode.DEVELOPER_ERROR from launchBillingFlowThe billing call is wrong (DEVELOPER_ERROR)Fix - 5
An error message in the purchase cart on an app that is in draft or only on the internal trackSpend limits on an unpublished appFix
- 1
What does the error look like?
An error message in the Google Play purchase cartBillingResponseCode.ITEM_UNAVAILABLEBillingResponseCode.BILLING_UNAVAILABLEBillingResponseCode.DEVELOPER_ERROR
Cause 1 of 5
The account on the device is not a license tester
1Check
Test purchases that avoid real charges only work for license testers. Confirm the Google Account that downloaded the app is on a license testing list, and that the account is on the device.
# On the device: Settings > Passwords & accounts, and the account shown in the Play Store profile menu2Fix
In Play Console open Monetization settings, then License testing, add the tester's Gmail address to an email list or Google Group, and save. Use that account on the device.
# Play Console > Manage account > Play apps settings
# > Monetization settings > License testing > add email list > Save changes3Verify
Start the purchase again. A test purchase shows a notice across the middle of the purchase dialog and offers test payment methods such as the always-approves one.
# Look for the 'Test instrument, always approves' payment method in the dialogConfirmed by developer.android.com
Cause 2 of 5
The product is not available to this user (ITEM_UNAVAILABLE)
1Check
A product can only be bought when it is active, its app is published, and the app is available in the user's country. Run the product query and see whether the product id comes back.
val params = QueryProductDetailsParams.newBuilder()
.setProductList(listOf(
QueryProductDetailsParams.Product.newBuilder()
.setProductId("premium_upgrade")
.setProductType(BillingClient.ProductType.INAPP)
.build()))
.build()
billingClient.queryProductDetailsAsync(params) { result, details ->
Log.d("Billing", "code=${result.responseCode} found=${details.productDetailsList.size}")
}2Fix
Activate the product in Play Console, publish the app to at least a testing track, and make sure the tester's country is included. If everything is correct and it still fails right after a change, wait: product details can take time to spread across Google's servers.
# Play Console > Monetize with Play > Products > In-app products
# > open the product > Activate3Verify
queryProductDetailsAsync returns the product with response code OK, and the purchase sheet opens.
# found=1 in the log line aboveConfirmed by developer.android.com
Cause 3 of 5
The Play Store cannot sell to this user right now (BILLING_UNAVAILABLE)
1Check
Google lists these situations: the Play Store app is out of date, the user is in an unsupported country, an enterprise admin blocked purchases, the payment method cannot be charged, or the Play Store is blocked by the system (the debug message says Play Store is blocked).
# On the device: Play Store > profile icon > Settings > About > Play Store version2Fix
Update the Play Store, use a device or profile that is allowed to buy, or fix the payment method. A manual retry works only after that condition is gone, so show a Try again button instead of retrying in a loop.
# On the device: Play Store > profile icon > Settings > About > Update Play Store3Verify
Try the purchase again after the change and read the new response code.
# The Billing log line now shows a different code, or OKConfirmed by developer.android.com
Cause 4 of 5
The billing call is wrong (DEVELOPER_ERROR)
1Check
DEVELOPER_ERROR means an API was used wrongly, for example wrong parameters passed to launchBillingFlow. Read the debug message, then compare the ProductDetails and offer token you pass with the ones queryProductDetailsAsync returned.
Log.e("Billing", billingResult.debugMessage)2Fix
Build BillingFlowParams from a ProductDetails object you just queried, and for subscriptions pass the offer token of the chosen offer.
val productParams = BillingFlowParams.ProductDetailsParams.newBuilder()
.setProductDetails(productDetails)
.build()
val flowParams = BillingFlowParams.newBuilder()
.setProductDetailsParamsList(listOf(productParams))
.build()
billingClient.launchBillingFlow(activity, flowParams)3Verify
launchBillingFlow returns OK and the purchase sheet appears.
# billingResult.responseCode == BillingClient.BillingResponseCode.OKConfirmed by developer.android.com
Cause 5 of 5
Spend limits on an unpublished app
1Check
Apps in draft or on the internal test track have limits on daily transactions, per-order value and daily total spend. They reset every 24 hours.
# Compare the number and size of today's test purchases with the limits2Fix
Wait for the limits to reset, or publish the app to a closed, open or production track if your testing needs higher limits.
# Play Console > Test and release > Testing > Closed testing > Create release3Verify
The purchase goes through after the reset or after the release is live on the higher track.
# The order appears in Play Console > OrdersConfirmed by developer.android.com
How do I stop it coming back?
- Keep one dedicated license-tester account per developer and sign in with it on every test device.
- Log responseCode and debugMessage on every billing call, not only on failures you expect.
- Query product details before every purchase and only offer products that come back.
- Acknowledge each purchase: a license tester's purchase is refunded after 3 minutes when it is not acknowledged.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Mobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile apps
Android Studio cannot pair the phone over Wi-Fi
The Pair devices over Wi-Fi dialog lists no device
Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.
4 causes, each with a fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile apps
adb tcpip 5555 fails because no device is found
adb: more than one device/emulator
adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.
4 causes, each with a fix