Search code examples
androidin-app-purchasein-app-billingin-app-subscription

Getting error in querying item on older devices


I have implemented Billing library it works on Api level 28 but it does not work on api level 23 I am getting W/BillingClient: getSkuDetails() failed. Response code: 6

public void startConnection() {
    billingClient.startConnection(new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(BillingResult billingResult) {
            if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
                // The BillingClient is ready. You can query purchases here.
                List<String> skuList = new ArrayList<>();
                skuList.addAll(skuListFetchFromServer);
                SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
                params.setSkusList(skuList).setType(BillingClient.SkuType.SUBS);

                billingClient.querySkuDetailsAsync(params.build(),
                        new SkuDetailsResponseListener() {
                            @Override
                            public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList) {

                                for (SkuDetails details : skuDetailsList) {
                                    Log.w(TAG, "Got a SKU: " + details);
                                }
                            }

                        });
            }
        }

        @Override
        public void onBillingServiceDisconnected() {

        }
    });
}

Is this error releted to device, gmail account or Api level Please help me i have wasted lots of time finding the solution but can not fix it.


Solution

  • Google doesn't support IabHelper and the AIDL anymore for in app billing implementation, they are deprecated.

    For new projects the billing library should be used adding:

    implementation 'com.android.billingclient:billing:2.0.3'

    in your app build.gradle

    Using the billing library I have no problem to get price of items calling billingClient.querySkuDetailsAsync() even in an Android 4.1 phone