Play Billing Library v1.0:自动续订订阅未出现在queryPurchases结果中
queryPurchases() Hey there, let's break down why your auto-renewing subscription's Purchase object is no longer showing up in queryPurchases() results after those pre-release weeks. Here are the most likely fixes to check:
Update your Billing Library version
If your modified BillingManager is based on an older Billing Library (pre-4.0), Google Play's billing API has undergone changes that can break older query methods. The synchronousqueryPurchases()is deprecated in newer versions, replaced byqueryPurchasesAsync(). Upgrading to the latest stable library and adjusting your BillingManager to use async queries can resolve unexpected missing results.Verify your query timing and methods
Auto-renewal after a free trial has a small processing window—if you're querying immediately after the trial ends, the purchase might not have synced yet. Make sure you're not just querying on app launch:- Listen to the
PurchasesUpdatedListenerfor real-time updates when the subscription renews. - Use
queryPurchaseHistoryAsync()as a fallback to check past transactions, since this can confirm if the subscription actually renewed even if the current purchase list is delayed.
- Listen to the
Check test vs. production environment differences
Pre-release testing (internal/closed tests) behaves differently than open testing or production. Double-check:- Your test account hasn't hit Google Play's limit for repeated free trials of the same subscription.
- The subscription's pricing, renewal period, and status are correctly configured in the Play Console for your target environment.
- You're using the correct test SKUs and accounts linked to your project.
Confirm the subscription is actually active
A missing Purchase object might mean the auto-renewal failed. Check:- The user's payment method (expired card, insufficient funds) via the Play Console's order management for your test account.
- Error codes in
onPurchasesUpdated()—look for issues likeUSER_CANCELEDorBILLING_UNAVAILABLEthat might indicate a failed renewal.
Audit your modified BillingManager logic
Since you tweaked the sample BillingManager.java, a bug in your changes could be filtering out valid purchases. Compare your code to the latest official sample:- Ensure you're filtering for
Purchase.PurchaseState.PURCHASEDand using the correctSkuType.SUBSwhen querying. - Check if you accidentally modified the logic that processes or returns the query results.
- Ensure you're filtering for
内容的提问来源于stack exchange,提问作者stephent

