Edit: So the issue was on the Java side. The purchase finished listener wasn't being called. This was very helpful: IabHelper PurchaseFinishedListener
My Cocos2dx game runs fine on Android and iOS for the most part. Only think giving me trouble is Android In-App Billing.
I'm using JNI to call from C++ to Java. The Java code goes back and forth w/ Google Play billing system and ultimately calls back to the C++ code indicating how much treasure to give to the user (amount successfully purchased).
The call from Java back to C++ is doing something very strange. The C++ code that runs should update the display of two things. However it only updates one and it's not consistent. Also multiple calls from Java to C++ result in CCNodes ignoring touches and doing other strange things.
After reading up on similar issues I realized that perhaps the Java to C++ call wasn't on the main/UI thread. So I tried to fix that like this:
// Java code
IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() {
public void onConsumeFinished(Purchase purchase, IabResult result) {
if (result.isSuccess()) {
String sku = purchase.getSku();
if (sku.equals(IAB_ID_ABC)) {
me.runOnUiThread(new Runnable() {
public void run() {
callCppMethodFromJava_giveUserABC();
}
});
}
}
};
Here I'm trying to call giveUserABC on the main/UI thread. giveUserABC is called however it's exhibiting strange behavior as described above.
Another thing I tried is posting a notification via CCNotificationCenter in giveUserABC. This was a shot in the dark but I read that it worked somewhere for someone.
Unfortunately none of this has fixed the strange behavior. Any help in understanding and fixing this situation is greatly appreciated!