title: In-App billing with BillingClient. ResponceCode = -1. Service connection is disconnected
body: <p>In my application, a donation function was made. (The application with permission to purchase inside the application is available in google play and in the downloaded version, this function works) I did it using the easy library from <strong>anjlab</strong>. I started to update the application, and rewrote it at the same time on <strong>Kotlin</strong>. Donat stopped working for some reason. I decided to redo the code from the <strong>anjlab</strong> library to the new billing library from google. When I try to make a purchase, I get </p>
  
  <blockquote>
    <p>responseCode = -1 (service connection is disconnected). </p>
  </blockquote>
  
  <p>I tried to resume the connection using <code>startConnection</code> (this), tried to change the version in the <strong>gradle</strong>, loaded the new version into the library <strong>apk</strong>. Neither the old nor the new does not work (if you download from google play, the one that is published, it works). Code wrote on the guideline from Google. I test the application signed on a real device</p>
  
  <p><strong>SettingsFramgent.kt</strong> (only sacrament code)</p>
  
  <pre><code>package *
  
  import android.content.Intent
  import androidx.preference.PreferenceFragmentCompat
  import android.os.Bundle
  import android.widget.Toast
  import androidx.preference.Preference
  
  import com.starikov.datecalc.R
  
  class SettingsFragment : PreferenceFragmentCompat(), SettingsContract.View {
  
      private lateinit var presenter: SettingsContract.Presenter
  
      override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
          setPreferencesFromResource(R.xml.preferences, rootKey)
  
          presenter = SettingsPresenter(activity!!)
          presenter.attachView(this)
  
  val makeDonatePref: Preference = findPreference(MAKE_DONATE_KEY)!!
  
          makeDonatePref.setOnPreferenceClickListener { presenter.makeDonateClicked(); true }
  
          presenter.viewIsReady()
      }
  
      override fun showToast(resId: Int) {
          Toast.makeText(activity, resId, Toast.LENGTH_LONG).show()
      }
  
      override fun startActivity(intent: Intent) {
          activity!!.startActivity(intent)
      }
  
      override fun onDestroy() {
          super.onDestroy()
          presenter.detachView()
          if (activity!!.isFinishing) {
              presenter.destroy()
          }
      }
  
      companion object {
          private const val MAKE_DONATE_KEY = "make_donate"
      }
  }
  
  </code></pre>
  
  <p><strong>SettingsPresenter.kt</strong></p>
  
  <pre><code>package *
  
  import android.app.Activity
  import android.content.ActivityNotFoundException
  import android.content.Intent
  import android.net.Uri
  import com.android.billingclient.api.*
  
  import com.starikov.datecalc.common.PresenterBase
  import com.android.billingclient.api.BillingClient
  import com.android.billingclient.api.SkuDetailsParams
  import com.android.billingclient.api.BillingFlowParams
  import com.starikov.datecalc.R
  import java.util.*
  
  
  internal class SettingsPresenter internal constructor(private val activity: Activity)
      : PresenterBase&lt;SettingsContract.View&gt;(), SettingsContract.Presenter {
      private lateinit var billingClient: BillingClient
      private var skuDetailsMap: HashMap&lt;String, SkuDetails&gt; = HashMap()
  
      override fun makeDonateClicked() {
          initBillingProcessor()
          launchBilling(DONATE_PRODUCT_ID)
      }
  
      override fun destroy() {
          billingClient.endConnection()
      }
  
      override fun viewIsReady() {}
  
      private fun initBillingProcessor() {
          billingClient = BillingClient.newBuilder(activity)
                  .enablePendingPurchases()
                  .setListener {
              billingResult, purchases -&gt;
              if (billingResult?.responseCode == BillingClient.BillingResponseCode.OK &amp;&amp; purchases != null) {
                  //purchase done
                  view!!.showToast(R.string.thanks_for_donate)
              }
          }.build()
  
          billingClient.startConnection(object : BillingClientStateListener {
              override fun onBillingSetupFinished(billingResult: BillingResult?) {
                  if (billingResult?.responseCode == BillingClient.BillingResponseCode.OK) {
                       // **place of logs**
                      querySkuDetails() 
                  }
              }
  
              override fun onBillingServiceDisconnected() {
                  //if wrong
              }
          })
      }
  
      private fun launchBilling(skuId: String) {
          val billingFlowParams = BillingFlowParams.newBuilder()
                  .setSkuDetails(skuDetailsMap[skuId])
                  .build()
          billingClient.launchBillingFlow(activity, billingFlowParams)
      }
  
      private fun querySkuDetails() {
          val skuDetailsParamsBuilder = SkuDetailsParams.newBuilder()
          val skuList = ArrayList&lt;String&gt;()
          skuList.add(DONATE_PRODUCT_ID)
          skuDetailsParamsBuilder.setSkusList(skuList).setType(BillingClient.SkuType.INAPP)
          billingClient.querySkuDetailsAsync(skuDetailsParamsBuilder.build()) { billingResult, skuDetailsList -&gt;
              if (billingResult?.responseCode ==  BillingClient.BillingResponseCode.OK) {
                  for (skuDetails in skuDetailsList!!) {
                      skuDetailsMap[skuDetails.sku] = skuDetails
                  }
              }
          }
      }
  
      companion object {
          private const val DONATE_PRODUCT_ID = "donate"
      }
  }
  
  </code></pre>
  
  <p>In "<strong>place of logs</strong>", i checked <strong>billingResult.responseCode = -1; debugMessage = "Service connection is disconnected"</strong></p>
  
  <p>I have no idea what to do. Thanks in advance for your help</p>