android billing how to enable enablePendingPurchases()

From the first stacktrace in your question

Enable this by calling 'enablePendingPurchases()'

we can find documentation for method enablePendingPurchases()

This method is required to be called to acknowledge your application has been updated to support purchases that are pending. Pending purchases are not automatically enabled since your application will require updates to ensure entitlement is not granted before payment has been secured. For more information on how to handle pending transactions see https://developer.android.com/google/play/billing/billing_library_overview

If this method is not called, BillingClient instance creation fails.

Your line of code should be:-

enablePendingPurchases = BillingClient.newBuilder(this)
   .enablePendingPurchases()
   .setListener(this);

Instead of :-

enablePendingPurchases = BillingClient.newBuilder(this).setListener(this);

This worked for me.

Just add enablePendingPurchases() like below:

billingClient = BillingClient.newBuilder(this)
                             .setListener(this)
                             .enablePendingPurchases()
                             .build();

BillingClient billingClient = 
BillingClient.newBuilder(context!!)
.enablePendingPurchases()
.setListener(this)
 build()
    billingClient.startConnection(object : BillingClientStateListener {
        override fun onBillingSetupFinished(billingResult: BillingResult) {
            if (billingResult.responseCode==BillingClient.BillingResponseCode.OK) {
                skuList =  HashMap()
                skuList.put(BillingClient.SkuType.SUBS, listOf(getString(R.string.subscription_monthly),getString(R.string.subscription_yearly)))

                querySkuDetailsAsync(BillingClient.SkuType.SUBS,skuList.get(BillingClient.SkuType.SUBS),object :SkuDetailsResponseListener{
                    override fun onSkuDetailsResponse(billingResult: BillingResult?, skuDetailsList: MutableList<SkuDetails>?) {

                        DebugLog.e("DATAAA "+skuDetailsList?.size+"")
                    }
                })
            }
        }
        override fun onBillingServiceDisconnected() {
            // Try to restart the connection on the next request to
            // Google Play by calling the startConnection() method.
        }
    })