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 !!!
![]()
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 ![]()
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.
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? ![]()
Has anybody got any suggestions?
EDIT: problem solved! In my test harness, I was trying to consume an item that wasnāt a consumable
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�!
![]()
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⦠![]()
Android and Play Store are a whole different level of pain ![]()
Hope you figure it out
Thank you @benediktadams ![]()
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
