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

GMG
  • 1,498
  • 14
  • 20
  • need log in querySkuDetailsAsync – Style-7 Nov 30 '19 at 07:38
  • @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. – Egemen Sep 07 '21 at 19:03

1 Answers1

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) {
                }
            });
        });
    }
from56
  • 3,976
  • 2
  • 13
  • 23
  • Just done in one of the many tests, but nothing, callbacks is never called – GMG Nov 30 '19 at 12:47
  • 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 ? – from56 Nov 30 '19 at 15:28
  • Do you have multiple Google accounts on the testing device? – from56 Nov 30 '19 at 15:36