Google Play Billing library 5 requirement

147 Views Asked by At

After a week of trying to find a solution, I am quite desperate to find (and I have read everything related to the topic) any way to resolve the issue.

I am trying to use Google Play Billing library 5 (as required by Google) in my Android App. However, I had created my app 8 years ago in Eclipse (in Java, not Android Studio), so please mind I am just trying to keep my app updated (over 30k daily users) and I may have made some beginners mistakes like missing something in AndroidManifest.xml. I am able to include the library (version 5.0) in my build and after calling:

billingClient.startConnection(new BillingClientStateListener() {
    @Override
    public void onBillingSetupFinished(BillingResult billingResult) {
        if (billingResult.getResponseCode() ==  BillingResponseCode.OK) {
            // The BillingClient is ready. You can query purchases here.
        }
    }
    @Override
    public void onBillingServiceDisconnected() {
        // Try to restart the connection on the next request to
        // Google Play by calling the startConnection() method.
    }
});

The response code is BillingResponseCode.OK, then I queryProductDetailsAsync() and I am able to get all items from my Google Play Console successfully (I get all the details like prices etc., so it means I am able to connect to Google). However, as soon as I call billingClient.launchBillingFlow(activity, billingFlowParams); my listener:

void onPurchasesUpdated(BillingResult billingResult, List<Purchase> purchases) {
    if (billingResult.getResponseCode() == BillingResponseCode.OK
        && purchases != null) {
        for (Purchase purchase : purchases) {
            handlePurchase(purchase);
        }
    } else if (billingResult.getResponseCode() == BillingResponseCode.USER_CANCELED) {
        // Handle an error caused by a user cancelling the purchase flow.
    } else {
        // Handle any other error codes.
    }
}

get a response code billingResult.getResponseCode() with value SERVICE_DISCONNECTED (-1) with getDebugMessage() stating "Service connection is disconnected". Even if I call functions (after the service disconnected message) like getConnectionState(), I am getting response CONNECTED (2) and also function isReady() is returning true where Google says it means "Checks if the client is currently connected to the service, so that requests to other methods will succeed."

After so many attempts over last week, I am unable to find any solution to this issue (reconnecting etc.). Thank you a lot for any possible solution for my issue.

0

There are 0 best solutions below