Android billingclient API version

What am I missing?

Sorry for the delay in responding here, and thanks for your patience.

We’ve updated the develop branch, so that new Android projects with in-app purchase support will now use version 5.0.0 of the BillingClient library.

Please try testing with the newest version of JUCE and let us know if you encounter any new issues.

THANKS Reuk !!!
:star_struck:

Hi @reuk

I’ve got a lot of success with the Android Purchase API for JUCE, and can query products, make purchases etc. - thank you very much for making this all work :slight_smile:

However, I’m getting a consistent crash when calling consumePurchase.

I’m using BillingClient 5.0.0, and am making this call from the main thread, JUCE 6.

juce::InAppPurchases::getInstance()->consumePurchase (theProductId, purchaseToken);
...
consumePurchaseWithToken (productIdentifier, purchaseToken);
...
        getEnv()->CallObjectMethod (billingClient,
                                    JuceBillingClient.consumePurchase,
                                    LocalRef<jstring> { javaString (productIdentifier) }.get(),
                                    LocalRef<jstring> { javaString (purchaseToken) }.get());

The crash log is of this form:

07-10 08:12:41.223 32439 32439 F DEBUG   : Abort message: 'JNI DETECTED ERROR IN APPLICATION: the return type of CallObjectMethodV does not match void com.rmsl.juce.JuceBillingClient.consumePurchase(java.lang.String, java.lang.String)
07-10 08:12:41.223 32439 32439 F DEBUG   :     in call to CallObjectMethodV
07-10 08:12:41.223 32439 32439 F DEBUG   :     from void com.rmsl.juce.JuceBillingClient.purchaseCompletedCallback(long, com.android.billingclient.api.Purchase, int)'
0

Just to confirm that the corresponding Java code (JuceBillingClient.java) looks like this:

    public void consumePurchase(final String productIdentifier, final String purchaseToken) {

which seems to be the correct signature!

Have you got any advice?!

Best wishes, Pete

My temporary hack-around was to remove the call from my .cpp code to handle consumption, and hack the .java file to consume the IAP instead…:

    private void handlePurchase(final Purchase purchase, final int responseCode) {

        // MPC - added to prevent crash (begin)
        String purchaseToken = purchase.getPurchaseToken();
        if (purchaseToken != "") {
            for (String productId : purchase.getProducts()) {
                consumePurchase(productId, purchaseToken);
            }
        }
        // MPC - added to prevent crash (end)

Please could you check whether swapping CallObjectMethod for CallVoidMethod at juce_android_InAppPurchases.cpp:548 resolves the crash? That seems to resolve the issue here.

1 Like

Thanks @reuk, will do! Pete

Thanks for your patience. I’ve made that change on develop now:

Thanks @reuk!

Pete

Hi @reuk

I’m just getting back to doing some maintenance on my IAP engine.

I have today found than when I call consumePurchase, I get error code 6 and ā€œGeneric errorā€.

Is this something unique to me? :slight_smile:

Has anybody got any suggestions?

EDIT: problem solved! In my test harness, I was trying to consume an item that wasn’t a consumable :slight_smile: I’ll keep this post here in case it helps somebody else.

Best wishes, Pete

So now I’m finding that as a result to a call to InAppPurchases::getProductsInformation(), my implementation of purchasesListRestored(…) is called with nothing in it, even through purchases have been made, and can be viewed in the Google Play console!

Arrgh! Pete

Edit: Having seen this

I wonder if I just need to wait for a couple of days…?!

:slight_smile:

Hey @peteatjuce

I remember this… I spent two whole days on this back then and reverted my implementation at the end of every day because the array just always came up empty. Next morning I booted up, just built the same thing that didn’t work for 2 days and there it was working… :magic_wand:

Android and Play Store are a whole different level of pain :melting_face:

Hope you figure it out

1 Like

Thank you @benediktadams :slight_smile:

Best wishes, Pete

Here I am re-testing Google Play Store IAP purchases a year later, and I have re-discovered that the purchase list isn’t always getting restored. So frustrating!

Best wishes, Pete

Hi again @reuk (and @benediktadams),

I’ve just found this link:

Which says this:

you need to wait for the billingClient.startConnection() call to finish doing it’s thing and onBillingSetupFinished() callback gets called on the provided BillingClientStateListener. Only after that you can call the queryPurchases method. If you call queryPurchases beforee finishing the connection to the service, you will get an empty list.

The JUCE implementation doesn’t work like that, from what I can see in the JUCE Java source code.

I can’t see any obvious way that I can directly modify the Java code in JUCE to try this out (as it is pre-compiled as binary data into the JUCE sources - I think!).

So - wondering if there is an issue within the JUCE IAP API for Android that needs resolving to fix this.

Best wishes, Pete