I have an Android app that's already published on Google Play. I am now trying to update the Billing Library from v2 to v4. Connection to Google Play works fine; however, getting SKU details with BillingClient#querySkuDetailsAsync
does not return anything.
I saw a similar question in this post, but as far as I see the suggested solution applies to apps that aren't published yet.
Another similar post suggests using BillingClient.SkuType.SUBS
instead of BillingClient.SkuType.INAPP
. Although that's wrong in my case, I've still tried it, but I am still not getting any results.
Here is the relevant code:
private BillingClientStateListener clientStateListener() {
return new BillingClientStateListener() {
@Override
public void onBillingServiceDisconnected() {
activity.logWarn("Billing service disconnected, trying again...");
// TODO try to reconnect
}
@Override
public void onBillingSetupFinished(@NonNull BillingResult billingResult) {
if (isBillingResultSuccessful(billingResult, CONNECTING)) {
activity.logInfo("Successfully connected to billing service");
fetchSkuDetails();
}
}
};
}
private void fetchSkuDetails() {
activity.logInfo("Fetching SKU details...");
billingClient.querySkuDetailsAsync(
createSkuDetailsParams(),
(billingResult, skuDetailsList) -> {
activity.hideProgressBar();
activity.logInfo("Received SKU response. Billing result: %s, sku list size: %d",
billingResult, skuDetailsList.size());
if (isBillingResultSuccessful(billingResult, RETRIEVING_PRODUCTS)) {
addProducts(skuDetailsList);
skuResponseListener.onSkuDetailsResponse(skuDetailsList);
}
});
}
private SkuDetailsParams createSkuDetailsParams() {
List<String> skuList = new ArrayList<>(NUM_COIN_PRODUCTS);
for (int i = 1; i <= NUM_COIN_PRODUCTS; i++) {
skuList.add(PRODUCT_ID_PREFIX + i);
}
return SkuDetailsParams.newBuilder()
.setSkusList(skuList)
.setType(SkuType.INAPP)
.build();
}
The last log entry I see is "Fetching SKU details...", but the callback event is never called after that. The product ids I add to SKU list already exist and in app purchases work with my production app.
What could be the problem?