title: Android BillingClient Error: "Exception while launching billing flow: ; for sku: android.test.purchased; try to reconnect"
body: <p>I have been trying to build an android application with in app payments, and am having trouble setting it up. I am calling the following:</p>
  
  <pre><code>      Activity activity = new Activity();
        billingClient = BillingClient.newBuilder(this).setListener(this).build();
        billingClient.startConnection(new BillingClientStateListener() {
            @Override
            public void onBillingSetupFinished(@BillingResponse int billingResponseCode) {
                if (billingResponseCode == BillingResponse.OK) {
                    List&lt;String&gt; skuList = new ArrayList&lt;&gt; ();
                    skuList.add("android.test.purchased");
                    SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
                    params.setSkusList(skuList).setType(SkuType.INAPP);
                    billingClient.querySkuDetailsAsync(params.build(),
                            (responseCode, skuDetailsList) -&gt; {
                                if (responseCode == BillingResponse.OK
                                        &amp;&amp; skuDetailsList != null) {
                                    for (SkuDetails skuDetails : skuDetailsList) {
                                        System.out.println("The price is "+skuDetails.getPrice());
                                        BillingFlowParams flowParams = BillingFlowParams.newBuilder().setSkuDetails(skuDetails).build();
                                        int code = billingClient.launchBillingFlow(activity,flowParams);
                                        System.out.println("Code is: "+code);
                                    }
                                }
                            });
                }
            }
            @Override
            public void onBillingServiceDisconnected() {
                System.out.print("Billing disconnected?");
            }
        });
  </code></pre>
  
  <p>When I run this, I get that the code is -1, and I get the error: <code>Exception while launching billing flow: ; for sku: android.test.purchased; try to reconnect</code> I found that the error code -1 is "Play Store service is not connected now - potentially transient state" (<a href="https://developer.android.com/reference/com/android/billingclient/api/BillingClient.BillingResponse" rel="noreferrer">https://developer.android.com/reference/com/android/billingclient/api/BillingClient.BillingResponse</a>). I have tried both the testing productIDs (<code>android.test.purchased</code>), as well as a real one that I created, with the same results. I have also restarted the (physical) device. I can access the Play Store app like normal, so I can't figure out what I am doing wrong here. </p>