GPG sign in error Cocos Creator


this is the error i get inside apk this is the label gpg logs to

this is my code

onLoad () {
    this.initPlugin();
    this.onSgn();
    
},

 initPlugin: function() {
    this.initPluginGPG();
},

initPluginGPG: function() {
    if ('undefined' == typeof gpg) {
        this.log('gpg is undefined');
        return;
    }

    const config = new gpg.PlatformConfiguration();
    config.SetClientID('MY PRIVATE CLIENT ID I ACTUALLY DONT KNOW IF I SHOULD HIDE IT BUT WHATEV');

    const l = 1;
    this.gameServices = null;
    this.signIn = false;
    const self = this;
    new gpg.GameServices.Builder()
        .SetOnAuthActionStarted (
            function(result) {
                self.log('GPG on auth action start');
            }
        ).SetOnAuthActionFinished (
            function(result) {
                self.log('GPG on auth action finished: ' + result.AuthOperation + ' ' + result.AuthStatus);
                self.signIn = gpg.IsSuccess(result.AuthStatus);
                self.log('GPG signed in:' + self.signIn);
            }
        ).SetOnMultiplayerInvitationEvent(
            function(result) {
                self.log('GPG on multiplayer invitation');
            }
        ).SetLogging(gpg.LogLevel.INFO)
        .EnableSnapshots() // Android: if login failed, plz comment this line and disable "cloud_save": false, with sdkbox_config.json file
        .Create(
            function(gs) {
                if (gs) {
                    self.gameServices = gs;
                    self.log('GPG game services connect');
                } else {
                    self.log('GPG game services not connect')
                }
            }, config);
},

onSgn: function() {
    if (null == this.gameServices) {
        this.log('GPG game services is null');
        return;
    }
    if (this.signIn) {
        this.log('GPG to sign out ...');
        this.gameServices.SignOut();
    } else {
        this.log('GPG to sign in ...');
        this.gameServices.StartAuthorizationUI();
    }
},

log: function(s) {
    cc.log(s);
    let lines = this.logs.string.split('\n');
    while (lines.length > 5) {
        lines.shift();
    }
    lines.push(s);
    this.logs.string = lines.join('\n');
},

Enabledsnapshots() <- remove

Or sdkboxplay usefull

i already tried commenting .EnableSnapshots couldn’t find cloud save in sdkbox json tho

what do you mean sdkboxplay ?

EnabledSnapshots() <–Deprecation

https://developers.google.com/drive/android/deprecation

/////////// i have sdkboxplay

Sdkbox 에 gps를 사용하여 로그인 하는 방법이 있다

그러나 그방법 말고 Sdk중 SDKBox Play sdk를 사용해서 로그인 하는 방법도 가능하다

이런방식으로 하게 되면 구글서비스 유니크 아이디 및 개인 정보를 가져 올수 있다

SDKBox Launcher를 켜면 아래와같이 설치 가능한 Sdk가 나오는데

SDKBox Play를 설치 하게 되면

빌드 폴더에 아래와 같이 설치 된다

그리고

AppDelegate.cpp

\build\jsb-default\frameworks\runtime-src\Classes

아래와 같이 추가 해준다

#ifdef SDKBOX_ENABLED
#include “PluginSdkboxPlayJS.hpp”
#include “PluginSdkboxPlayJSHelper.h”
#endif

#ifdef SDKBOX_ENABLED
se->addRegisterCallback(register_all_PluginSdkboxPlayJS);
se->addRegisterCallback(register_all_PluginSdkboxPlayJS_helper);
#endif

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
se->addRegisterCallback(register_all_PluginSdkboxPlayJS);
se->addRegisterCallback(register_all_PluginSdkboxPlayJS_helper);
#endif

다음으로 Google AppId 를 넣어준다

\build\jsb-default\frameworks\runtime-src\proj.android-studio\app\res\values\string.xml

<?xml version='1.0' encoding='UTF-8'?> googletestapp nearby_service_id *********

Client Js Or Ts

//클릭시 SDKBox Play 로그인 및 로그 아웃 
onClickSDKBoxPlaySign() {
    if (sdkbox.PluginSdkboxPlay.isSignedIn()) {
        sdkbox.PluginSdkboxPlay.signout();
    } else {
        sdkbox.PluginSdkboxPlay.signin(true);
    }
}

//클릭시 SDKBox Play를 초기화 시켜준다 
onClickSDKBoxPlayInit() {
    var me = this;

    var initSDK = () => {
        if ("undefined" == typeof (sdkbox)) {
            cc.log("sdkbox is not exist")
            return
        }

        if ("undefined" != typeof (sdkbox.PluginSdkboxPlay)) {
            var plugin = sdkbox.PluginSdkboxPlay
            plugin.setListener({
                onConnectionStatusChanged: (connection_status) => {
                    cc.log("connection status change: " + connection_status + " connection_status");
                    if (connection_status == 1000) {
                        //구글 플레이 고유 아이디 및 계정 이름 
                        cc.log('Player id: ' + plugin.getPlayerId());
                        cc.log('Player name: ' + plugin.getPlayerAccountField("name"));

                        this.label.string += plugin.getPlayerId()
                        this.label.string += plugin.getPlayerAccountField("name");
                        //  me.info.setString("connection status: " + connection_status + " " + plugin.getPlayerId() + " " + plugin.getPlayerAccountField("name") + "(" + plugin.getPlayerAccountField("display_name") + ")");
                    } else {
                        // me.info.setString("Not connected. Status: " + connection_status);
                    }
                },
                onScoreSubmitted: function (leaderboard_name, score, maxScoreAllTime, maxScoreWeek, maxScoreToday) {
                    cc.log('onScoreSubmitted trigger leaderboard_name:' + leaderboard_name + ' score:' + score + ' maxScoreAllTime:' + maxScoreAllTime + ' maxScoreWeek:' + maxScoreWeek + ' maxScoreToday:' + maxScoreToday);
                },
                onMyScore: function (leaderboard_name, time_span, collection_type, score) {
                    cc.log('onMyScore trigger leaderboard_name:' + leaderboard_name + ' time_span:' + time_span + ' collection_type:' + collection_type + ' score:' + score);
                },
                onMyScoreError: function (leaderboard_name, time_span, collection_type, error_code, error_description) {
                    cc.log('onMyScoreError trigger leaderboard_name:' + leaderboard_name + ' time_span:' + time_span + ' collection_type:' + collection_type + ' error_code:' + error_code + ' error_description:' + error_description);
                },
                onPlayerCenteredScores: function (leaderboard_name, time_span, collection_type, json_with_score_entries) {
                    cc.log('onPlayerCenteredScores trigger leaderboard_name:' + leaderboard_name + ' time_span:' + time_span + ' collection_type:' + collection_type + ' json_with_score_entries:' + json_with_score_entries);
                },
                onPlayerCenteredScoresError: function (leaderboard_name, time_span, collection_type, error_code, error_description) {
                    cc.log('onPlayerCenteredScoresError trigger leaderboard_name:' + leaderboard_name + ' time_span:' + time_span + ' collection_type:' + collection_type + ' error_code:' + error_code + ' error_description:' + error_description);
                },
                onIncrementalAchievementUnlocked: function (achievement_name) {
                    cc.log("incremental achievement " + achievement_name + " unlocked.");
                },
                onIncrementalAchievementStep: function (achievement_name, step) {
                    cc.log("incremental achievent " + achievement_name + " step: " + step);
                },
                onIncrementalAchievementStepError: function (name, steps, error_code, error_description) {
                    cc.log('onIncrementalAchievementStepError trigger leaderboard_name:' + name + ' steps:' + steps + ' error_code:' + error_code + ' error_description:' + error_description);
                },
                onAchievementUnlocked: function (achievement_name, newlyUnlocked) {
                    cc.log('onAchievementUnlocked trigger achievement_name:' + achievement_name + ' newlyUnlocked:' + newlyUnlocked);
                },
                onAchievementUnlockError: function (achievement_name, error_code, error_description) {
                    cc.log('onAchievementUnlockError trigger achievement_name:' + achievement_name + ' error_code:' + error_code + ' error_description:' + error_description);
                },
                onAchievementsLoaded: function (reload_forced, json_achievements_info) {
                    cc.log('onAchievementsLoaded trigger reload_forced:' + reload_forced + ' json_achievements_info:' + json_achievements_info);
                },
                onSetSteps: function (name, steps) {
                    cc.log('onSetSteps trigger name:' + name + ' steps:' + steps);
                },
                onSetStepsError: function (name, steps, error_code, error_description) {
                    cc.log('onSetStepsError trigger name:' + name + ' steps:' + steps + ' error_code:' + error_code + ' error_description:' + error_description);
                },
                onReveal: function (name) {
                    cc.log('onReveal trigger name:' + name);
                },
                onRevealError: function (name, error_code, error_description) {
                    cc.log('onRevealError trigger name:' + name + ' error_code:' + error_code + ' error_description:' + error_description);
                },
                onGameData: function (action, name, data, error) {
                    if (error) {
                        // failed
                        cc.log('onGameData failed:' + error);
                    } else {
                        //success
                        if ('load' == action) {
                            cc.log('onGameData load:' + name + ':' + data);
                        } else if ('save' == action) {
                            cc.log('onGameData save:' + name + ':' + data);
                        } else {
                            cc.log('onGameData unknown action:' + action);
                        }
                    }
                }
            });
            plugin.init();

            // ref to http://discuss.cocos2d-x.org/t/sdkbox-play-savegamedata-error/39367
            plugin.saveGameData("name", 'test'); // crash here ?

        } else {
            //  printf("no plugin init")
        }
    }

    initSDK();

}

sorry but i don’t understand anything :confused:

@yinjimmy hey can you help

  1. remove .EnableSnapshots() and test
  2. "cloud_save": false is for sdkboxplay plugin
1 Like

i did remove that and test but it didnt work

ok so i imported sdkboxplay and made sure it is false and its still not working

did you launch app with release mode ?

what do you mean release mode im using the apk inside release folder yes if thats what you are asking

ok.

could you plz check with : http://docs.sdkbox.com/en/plugins/googleplay/v3-cpp/#pre-requisites

1 Like

ok i did a new keystore and did new application on console got the new client id and tested with another build at different folder but still not working :frowning:

any other possible causes ?

publish your app to alpha / beta test. and and you as tester.

i did add myself and couple friends as tester but still it wont work

whats the logcat message,

Add this entry to proj.android/res/values/string.xml

<string name="google_app_id">you app id</string>

thats already in my string.xml but i dont know whats logcat message or how to view it

but this cc.log message i get

i need a solution please heeeeeeeeeeeeeeelllppppppppppppppppppppp

signed-in: true,

`GPG game services is null?"

let me check your code .

— split —

  1. GPG game services is null

because

    this.initPlugin();
    this.onSgn(); // (this.gameServices == null) log ("GPG game services is null")
  1. and then GPG game services connect

because connecting is async
self.gameServices = gs;

Thanks,

1 Like
onLoad () {
 this.initPlugin();    
},

initPlugin: function() {
    this.initPluginGPG();
},

initPluginGPG: function() {
    if ('undefined' == typeof gpg) {
        this.log('gpg is undefined');
        return;
    }

    const config = new gpg.PlatformConfiguration();
    

    const l = 1;
    this.gameServices = null;
    this.signIn = false;
    const self = this;
    new gpg.GameServices.Builder()
        .SetOnAuthActionStarted (
            function(result) {
                self.log('GPG on auth action start');
            }
        ).SetOnAuthActionFinished (
            function(result) {
                self.log('GPG on auth action finished: ' + result.AuthOperation + ' ' + result.AuthStatus);
                self.signIn = gpg.IsSuccess(result.AuthStatus);
                self.log('GPG signed in:' + self.signIn);
            }
        ).SetOnMultiplayerInvitationEvent(
            function(result) {
                self.log('GPG on multiplayer invitation');
            }
        ).SetLogging(gpg.LogLevel.INFO)
        .Create(
            function(gs) {
                if (gs) {
                    self.gameServices = gs;
                    self.log('GPG game services connect');
                } else {
                    self.log('GPG game services not connect')
                }
            }, config);
},

onSgn: function() {
    if (null == this.gameServices) {
        this.log('GPG game services is null');
        return;
    }
    if (this.signIn) {
        this.log('GPG to sign out ...');
        this.gameServices.SignOut();
    } else {
        this.log('GPG to sign in ...');
        this.gameServices.StartAuthorizationUI();
    }
},

log: function(s) {
    cc.log(s);
    let lines = this.logs.string.split('\n');
    while (lines.length > 5) {
        lines.shift();
    }
    lines.push(s);
    this.logs.string = lines.join('\n');
},

problem was with my account that i used for testing :frowning: @yinjimmy thank you so much for your help