I’ve been working on this all day, with no luck so far. I’m using cocos2d-x 3.10, and I’ve just added SDKBOX and IAP to my game, and the iOS side went without a problem. However, I can’t get the Android side to find any IAPs. I get the message “Google Play IAB hasn’t been initialized.” And the argument to onInitialized is 0.
I’ve tried several suggestions that I’ve found online, including deferring the IAP::refresh() until the onInitialized() method, but still no luck.
I uploaded a signed apk to Alpha testing and created two IAPs there, and my sdkbox_config.json is correct (the ids match what’s in GPS). I’ve run the app in release mode and debug mode, and neither works.
I’ve run out of ideas, so if anyone has any suggestions, I’d be very grateful!
Thanks, nite. I’ve been using that link, in fact. I appreciate it. I don’t know why it’s not working yet. I’m at my real job today, but I hope to be able to work on the app tonight.
If you can call the purchase function and send the screenshot that would be great, usually that error dialog tells you what’s wrong with the IAP setting.
I’m not getting a popup, but when I run “adb logcat” I get these lines:
D/IAP ( 836): payForProduct invoked com.batts.psf2016.playbooks_consumable and type: 0
D/IAP ( 836): GooglePlay result : 1 msg : Google Play IAB hasn’t been initilized.
I call IAP::init() in AppDelegate, and I have two classes, StoreManager and StoreDialog, that implement IAPListener. They work on iOS, but I must be missing something on the Android side. Maybe I’m logged in to the google play store incorrectly? I’m testing on a Kindle Fire and and old Samsung Galaxy.
nite, I’ve thought about it some more. I guess I can’t test on the Kindle Fire, since it doesn’t have Google Play Store installed. I do sell my game on the Amazon store, but I’m guessing that SDKBOX::IAP isn’t implemented for Amazon yet? I’m planning on designing my own wrapper at some point, because I have to get this working on Amazon and hopefully on Steam.
Thanks for your suggestions here and elsewhere. I’m looking around on the forums for people who have had similar problems, which got me to thinking it’s my devices or setups. Now, if that’s the case, I’ll need some way to detect that and let the user know they can’t buy IAPs.
One other thing, do you know how to print out and read statements from within a release build? I know CCLOG isn’t right, and I’ve tried fprintf to stderr and stdout, but not seeing any output in adb logcat. And I’m not getting a popup on Android, although the purchase call works on iOS and gives a popup on iOS.
I’ll be doggone, I didn’t realize that, LOL! Pretty simple to add debug to release after all - thanks!
Ok, this time I did get a pop up on the Samsung, saying “Authentication is required. You need to sign into your Google account.” But when I pull up the Play Store, it shows me logged in. Now I’m logged in with my real account, I don’t know if that matters.
well, I’m embarrassed! Thanks, nite. I just published the app, so I’ll test the IAP again tomorrow. Thank you very much for the link.
[edit] Ok, I just had to go ahead and test, and I’m now pulling information (prices, etc) from the Google Play store! I can’t buy yet (when I try I get a warning that it’s not available for purchase), but I think that’s just because it’s only been 15 minutes or so.
Thank you SO much! I can’t believe I kept missing the point that it had to be published - ugh.
Well, again, I just love cocos2d-x. IAP is much simpler using the SDKBOX approach, and works on both platforms, and I’ll add Android later. And I like that I’ll be able to use the LiveOps functionality later, too.