querySkuDetailsAsync callback never called
Asked Answered
S

1

6

I think to have followed all the steps correctly from the documentation but I can't reach the callback of querySkuDetailsAsync, no errors reported. The app is working correctly with IAB, now I'm only migrating from old library to the new 'com.android.billingclient:billing:2.0.3' but many problems. Another question, in the new library is also necessary the use of License Key from Play Console? I don't find documentation about using that in the new library.

I can correctly and without errors reach this line billingClient.querySkuDetailsAsync(params, (billingResult2, skuDetailsList) ->

Sku ids are correctly

    private void setupIab()
    {
        billingClient = BillingClient.newBuilder(getApplicationContext()).enablePendingPurchases().setListener(this).build();
        billingClient.startConnection(new BillingClientStateListener()
        {
            @Override
            public void onBillingSetupFinished(BillingResult billingResult)
            {
                if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK)
                {
                    List<String> skuList = new ArrayList<> ();
                    skuList.add("test_sku_1");
                    SkuDetailsParams params = SkuDetailsParams.newBuilder().setSkusList(skuList).setType(BillingClient.SkuType.INAPP).build();

                    billingClient.querySkuDetailsAsync(params, (billingResult2, skuDetailsList) ->
                    {
                        // Process the result.
                        if (billingResult2.getResponseCode() == BillingClient.BillingResponseCode.OK && skuDetailsList != null)
                        {
                        }
                    });

                }
            }

            @Override
            public void onBillingServiceDisconnected()
            {
                // Try to restart the connection on the next request to
                // Google Play by calling the startConnection() method.
            }
        });
    }

Best regards

Shalondashalt answered 29/11, 2019 at 19:57 Comment(2)
need log in querySkuDetailsAsyncMessina
@GMG: how did you fix this issue? I am now trying to update from v2 to v3, and I have the exact same problem. I could connect to the billing service; however, querySkuDetailsAsync callback is never called. I don't get any errors either.Antitank
S
0

The code seems correct form me and is similar to what I use, but I do not call querySkuDetailsAsync within onBillingSetupFinished, I call it only when the user buy something.

Maybe when onBillingSetupFinished runs, the setup is not really finished yet, you could try using this, so it will be called just later:

 if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
        new Handler().post(() -> {
            List<String> skuList = new ArrayList<>();
            skuList.add("test_sku_1");
            SkuDetailsParams params = SkuDetailsParams.newBuilder().setSkusList(skuList).setType(BillingClient.SkuType.INAPP).build();

            billingClient.querySkuDetailsAsync(params, (billingResult2, skuDetailsList) ->
            {
                // Process the result.
                if (billingResult2.getResponseCode() == BillingClient.BillingResponseCode.OK && skuDetailsList != null) {
                }
            });
        });
    }
Selenaselenate answered 30/11, 2019 at 12:40 Comment(3)
Just done in one of the many tests, but nothing, callbacks is never calledShalondashalt
So I think that your problem is probably not related to the code but to the settings on the Google Play Console. Have you at least uploaded a release APK ?Selenaselenate
Do you have multiple Google accounts on the testing device?Selenaselenate

© 2022 - 2024 — McMap. All rights reserved.