[SOLVED] Google Play IAB hasn't been initilized

[SOLVED] Google Play IAB hasn't been initilized
0.0 0

#1

Hi there! I’m trying to install SDKBOX 1.1.6 (latest release, if I’m not mistaken), into a Cocos2d-x v2.6 project, but it does not work in runtime. I’m quite confident that I’ve followed all the steps described in the file “installation_guide_cpp.pdf”, but I’m still stuck…

As soon as I try to run a refresh() request, I receive the error of the title (yes, the typo is there in the original output messagel). My Google Play Developer console seems to be properly configured, and all the InApps products are active. The json file seems fine, the key is also included, the app compiles flawlessly, and I’m running a release-signed version.

Any ideas of what could be wrong? Thanks!


#2

can you post any output from logcat?

also, check out the docs here: http://sdkbox-doc.github.io/en/plugins/iap/v2-cpp/


#3

I need more information in order to tell what’s going on.

Did your game crash? Or it’s just a google play dialog with error message.
If your game crashes, can you post crash log?
If it is just a google play error dialog, can you post the screenshot, I’ve seen almost all the error message now, should be able to help.


#4

Hi @nite! Thanks for your promptly reply.

No, my game doesn’t crash, it runs normally, it’s just the calls to any sdkbox::IAP method that fail (therefore, there are no Google Play dialogs yet). The error of the title, is the one I get as a string in the refresh() listener callback (onProductRequestFailure). You can download my whole log from here: https://copy.com/OAv7neGq9QAjAYEa

The important lines (or what I can see as “obvious”) are these:

07-21 01:53:50.987: I/SDKBox(21004): class name : ----com/sdkbox/plugin/SDKBoxIAPGooglePlay----
07-21 01:53:53.776: I/Native(21004): ERR: SDKBox IAP: failed to get configuration
07-21 01:53:53.776: I/Native(21004): INF: SDKBox IAP: refresh Products
07-21 01:53:53.776: I/Native(21004): INF: SDKBox IAP: Invalid name iap item name: com
07-21 01:53:50.994: D/cocos2d-x debug info(21004): onProductRequestFailure() -> Msg: Google Play IAB hasn’t been initilized.

Thanks!


#5

Did you publish your signed release version to an Alpha or Beta channel in Google Play?
I think this is necessary to test your IAP, even if the IAP shows as being active and you are running a signed release version.
http://developer.android.com/google/play/billing/billing_testing.html

Edit: I also had to wait about 3 hours after publishing my app to Alpha before it worked. Google says it can take up to 24 hours…


#6

It says SDKBOX failed to get the configuration, please double check your sdkbox_config.json
Also check your integration, Did you happens to change AppActivity.java instead of Cocos2dxActivity.java that will also result in this bug


#7

@Heyalda: Yes, I’ve read that, and I’m using a release signed build, already uploaded in GPlay. Thanks!

@nite: The file sdkbox_config.json is located in the Resources folder, so it gets copied into the assets folder inside the APK. Is this wrong? I’ve also tried copying it into my res folder, but then I get an error in Eclipse when trying the export.

What do you mean by “change AppActivity.java instead Cocos2dxActivity.java”? I was following the official guide, it speaks of adding the initialization and the overridden methods in MY main activity, not the base class: http://sdkbox-doc.github.io/en/plugins/iap/v2-cpp/

Thanks a lot for your support!


#8

Ok I see, can you call sdkbox::IAP::init() a bit later in your code, say when your first scene init


#9

Found the issue! @nite, you were right about double checking my sdkbox_config.json file :smile:

I’m not sure why, but my json used the character instead of " for the strings, probably messing with the parsing as a result. I don’t know… perhaps I copied the content from the web into TextEdit (instead of just renaming the sample file), and that changed those evil characters… anyway, it’s fixed now, and the inApps works well.

Thanks everybody for the big help!


#10

That’s great!


#11

Hi, I’m trying to integrate the SDKBOX IAP.
I follow all the different steps from the documentation but I can’t figure how to run my application as a release build. I’m using Eclipse and I don’t really understand what I’ve found on this subject. Please, help me…

For the moment, I got this message from Google Play:
“Authentication is required. You need to sign into your Google Account.”


#12

In Eclipse, just use File/Export and choose “Export Android Application” between the options. You’ll need to create a keystore file in order to sign your app for release. For more information on this subject, take a look at: http://developer.android.com/tools/publishing/app-signing.html


#13

Thanks for the answer, but I think I already done that:
I exported a signed Application Package. Then I uploaded this APK to Alpha testing in the Google Play Developer Console, and I published it. And I added the new in-app product.
Yesterday, to test the in-app as a developper, I run my application from eclipse to my device but it didn’t work. (I checked if the version in my AndroidManifest.xml matchs with the one uploaded to Google Play.)
Today, I run the APK file (the one I give to alpha testing) from my console with “adb” to see if it was that the problem but it didn’t work either…

PS:I didn’t remove all the CCLOGs.


#14

Okay, so I found the solution. My problem was that in my sdkbox_config.json file, the Id of my purchase was “com.mycompany.mygame.mypurchase” and the Id in the Play Store was just “mypurchase”, so nothing was called…

Silly mistake…


#15

Glad you solved it! :slight_smile:

I just discovered the 1.2.0.1 update to the IAP library. @nite, I noticed that now the sample json includes the “type” key-value pair inside the “android” section. The doc says its only for “non consumable” items, and only for Android. By non-consumable… does it refer to the managed type, inside Google Play? Should I then add this field, if I want to update SDKBOX?

EDIT: Ok, by reviewing the google documentation, I think that it relates to the consumable requests. I’m quite outdated with v3 API, uff: http://developer.android.com/google/play/billing/api.html


#16

The reason SDKBOX API worked this way is that I think Google play’s managed iap is quite hard to use, basically you can’t purchase something again if you didn’t consume it first. so we’re trying to replicate Apple Store’s iap, basically consumable and non-consumable.

If something is marked as non-consumable, user won’t be able to purchase it again, so it will work for something like remove ads, double the coin etc.


#17

Hello, I am having the same issue about the Google Play IAB not being initialized.

You mentioned that i should modify the Cocos2dxActivity.java Instead of the AppActivity.java. I have done this, however My question is WHICH Cocos2dxActivity.java should i modify? I seem to have 2, one is in the cocos2d-x installation folder:
(/Users/LuisOscar/Documents/cocos2d-x-3.6/cocos/platform/android/java/src/org/cocos2dx/lib)
And the other is in the project folder:
(/Users/LuisOscar/Documents/CocosProjects/MyGame/cocos2d/cocos/platform/android/java/src/org/cocos2dx/lib)

I use cocos console on the terminal to build and release, and i think that one doesn’t even check the cocos2d-x files that are in my project, i think that one checks directly the files that are at the installation folder. Should i change my console configuration to use the project one instead?

On a side note, could you be so kind to clarify why there is a copied cocos2d folder on every project i create? Isn’t the cocos console supposed to be using the ones that are at the installation one? I’m just confused because both folders seem to have the same things inside.

Thank you


#18

You should modify

/Users/LuisOscar/Documents/CocosProjects/MyGame/cocos2d/cocos/platform/android/java/src/org/cocos2dx/lib

Yes cocos console will create a copy of cocos2d-x, I was a decision made a while ago. the idea been, every game is different you might want to modify cocos2d-x source differently, I do believe, we need an option for people to use a shared engine core across all games…

I created a working sample for iap integration hope it helps
https://github.com/darkdukey/sdkbox-iap-sample


#19

Thanks for the fast reply, i’m going through the project that you shared to me, but i still haven’t managed to find out exactly why its not working.

When i open the scene for in app purchases the listener method for “initialized” is called with the ok value flag set to false. Any idea what could be causing this?

It works perfectly on iOS but not on android. As soon as I open the scene the game crashes because of an assert from CCVector that says that no objects where added. But this is probably because the IAP is not being initialized correctly on the first place.


#20

Can you share your log file from android?