[SDKBOX] GPG - Leaderboard - Example code - error

I’m having trouble sending and reading player scores.

I’m using the code below, as there are no examples to use, I’m trying to figure out how to use it. Can someone help me?

can you try our sample ?

I’m blocked with china great wall, can not connect to Google.

Okay, I’ll try, as soon as I can, I’ll make an article of it, … this is very complicated for beginners … and without documentation it gets even harder … tks…

That’s great !
Please help to improve our documentation, repo here.

I’m already giving up, I can not make the connection with google play game …
It’s been 3 weeks and I can not use or find an example made in cocos creator …:disappointed_relieved:

All right, we’ll provide an creator example for GPG.

creator project is same with -x project,you can check sdkbox -sample-gpg js project

have you tried sdkbox-sample-gpg js project, any problem?

Hey, Your error was connecting to google play fails. That code which you implemented in the block Create function work only game_services !== null, if it null message error undefined will return;
So How to make it work,

  1. Created Game service and config as google play needed.(I hope you did right)
  2. Get game services app ID no need OAuth2 Client ID(android). Go to Game detail -> under game display name like (874985934983)
  3. Add game ID into string xml under tag app_id or google_app_id
  4. Implement
    ex.
    new gpg.GameServices.Builder()
    .SetOnAuthActionStarted(function(result) {
    // Auth started callback
    })
    .SetOnAuthActionFinished(function(result) {
    this._signed_in = gpg.IsSuccess(result.AuthStatus);
    })
    .SetLogging(gpg.LogLevel.INFO) // Set Logging level
    .EnableSnapshots() // Enable Snapshot (Saved Game) functionailty
    .Create(function(game_services) {
    if(game_services !== null){
    //your code…
    }
    });
  5. Build & compile apk file (with release signed apk)
  6. Upload apk as alpha to google play and wait until it published.(Not to long)
  7. Add some tester by email address or you can set as open testing. (Share test link to tester).
  8. Download app and test it.
  9. logcat to investigate services process.(it helpful for me).
    NOT: it worked first for alpha apk and on the next time you have to promote to beta.

Hope it helped.

Thanks to all who are helping …

What I have done so far …, I decided to start creating everything from scratch, in order to solve the problems and to follow the steps that were said here.

1 - the error of: no authorization: no client. However I believe that I am configuring the client ID correctly as follows in image 2.

2 - code I am using to make the connection. ps.: I had to put the ‘this.node’ in the ‘create ()’ function, because within the function I was not recognizing the variable ‘me’

3 - string.xml

4 - From here I will show how it is configured in the google play console.

I’m sure I’m doing something wrong, I just do not see where.
And thanks again!

I tried to follow, but unhappily I could not. The error is down.

Many thanks, I followed your step several times, and I came across the following problem below.

i test sdkbox-sample-gpg js project just now, work fine. this is my steps:

  1. git clone git@github.com:sdkbox/sdkbox-sample-gpg.git
  2. entry sdkbox-sample-gpg js folder, cd sdkbox-sample-gpg/js
  3. update gpg plugin, by run sdkbox update
  4. run cocos run -p android -m release
  5. tap sign in menu on device
  6. tap leaderboard menu
  7. tap Show UI [Best gamers]
  8. work fine

Did you test with the data I passed? Of the service game

Need to test in RELEASE mode.

I know that is a big complication thing to do. And I have some more suggestion below.

  • I think if you define (var me = this) every code below in block function have to be (me.)

  • did you upload release signed apk to alpha release store?(your image show me about create game services but not release apk)

  • Let sort out the code to make sure services worked first, just the code below I have test, it worked for me.
    onLoad: function() {

      if (cc.sys.isMobile) {
          var self = this;
          if (!self.isInitialized()) {
              new gpg.GameServices.Builder()
                  .SetOnAuthActionStarted(function(result) {
                      // Auth started callback
                  })
                  .SetOnAuthActionFinished(function(result) {
                      self._signed_in = gpg.IsSuccess(result.AuthStatus);
                  })
                  .SetLogging(gpg.LogLevel.INFO) // Set Logging level
                  .EnableSnapshots() // Enable Snapshot (Saved Game) functionailty
                  .Create(function(game_services) {
                      self._game_services = game_services;
                  });
          }
    

    }

  • recommended test on real device, Because it has Play games app.

  • if you to want logcat native, you have create call native function(log as your code is not work in native).

NOT. You have more focus on reading doc carefully.

you can follow my steps, make sure sample is work for you.

and then, compare to your project

Hey @Celsomf how your work on gpg so far? I know maybe it too long day, But i am reworking on gpg today and i just meet the same error as the first of your logcat image.
SOLUTION:
** Add android-support-v4.jar

  • Android Studio / build.gradle automatically handles it inside module build.gralde
  • from ant build, just drop it into the libs directory
  • from eclipse, add dependencies, and also drop it into the libs folder INSIDE eclipse IDE
1 Like

Thanks for the answer…
I could not make that call, so I took a break, and I’m working on other parts of the project to take a breath and return to this problem … as soon as I make the changes I’m going to give a feedback here. =)