Gamenetwork does not init

Hello,

I need to update apps on Android that use the Gamenetwork plugin. It is the same code that worked a few months ago, but now it doesn’t init any more. Should this work, or what exactly does “legacy” for the plugin mean?

I use Build 2016.2992.

local function initCallback( event ) gameNetwork.request( "login", { userInitiated=true, listener=gameNetworkLoginCallback } ) native.showAlert( "Alert", "", {"OK"}) -- This alert is never shown, so it does not init. end gameNetwork.init("google", initCallback)

 plugins = { ["plugin.google.play.services"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, ["CoronaProvider.gameNetwork.google"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, ["facebook"] = { publisherId = "com.coronalabs" }, ["CoronaProvider.native.popup.social"] = { publisherId = "com.coronalabs", }, ["plugin.appodeal"] = { publisherId = "com.coronalabs", supportedPlatforms = {android=true} }, },

Hi @philipp3,

If you’re updating these apps, I highly highly recommend that you update your Google Play Games Services code to the new GPGS plugin (not the legacy one). The new one, while technically compatible with legacy code, is vastly better and more complete with many more features that the legacy plugin will never see. It makes sense IMHO to adjust your code to be future-proof using the newer plugin.

https://docs.coronalabs.com/plugin/gpgs/index.html

Best regards,

Brent

Thanks Brent,

I am trying to update an app with gpgs, but the app starts with the Runtime Error:

/User/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:853: module ‘plugin.gpgs’ not found:resource(plugin.gpgs.lu) does not exist in archive

… (and so on)

I think I have completed every step in the documentation, am I missing something?

You probably need to use daily build 3005 or later (recommend 3031 or later).

Rob

Thanks, now init works. But for some reason, the listener function of gpgs.players.load is not called. And I don’t know if I need that for showing the leaderboards, but that doesn’t work for me, too (also not sure if I have to load them first).

local playerName = "player" local function loadLocalPlayerCallback( event ) -- This function is not called if #event.players \> 0 then playerName = event.players[1].name end end local function gameNetworkLoginCallback( event ) gpgs.players.load({listener = loadLocalPlayerCallback}) end local function initCallback( event ) gpgs.login({listener=gameNetworkLoginCallback}) end gpgs.init(initCallback)

local function showNow()     gpgs.leaderboards.show() end gpgs.leaderboards.load({listener = showNow})

The first thing I would to is put a print statement in showNow that’s going to print out the values passed in. Secondly gpgs.leaderboards.show() requires a parameter of the leaderboard to show. Finally gpgs.leaderboards.load()'s purpose is to get  you the leaderboard’s data in data form so you can show it however you like.

Try this:

local function showNow() &nbsp; &nbsp; gpgs.leaderboards.show("CgkIltz19SWDJFK13g") &nbsp;--\<------ use your own leaderboard ID from the Google Play developer console. Or leave blank. end showNow()

Of if you really want to use the data version:

local function showNow( event ) print( json.prettify( event ) ) end gpgs.leaderboards.load({listener = showNow})

Now you can look in your console.log and see what data is being returned by gpgs.leaderboards.load().

Rob

Got it, thank you, I will try that tomorrow.

Any idea why the loadLocalPlayerCallback function from the previous post won’t get called?

Okay, I have tried it for several hours and with several constellations, but the following things never worked:

gpgs.login() does not bring up a banner or something if the user is logged in, but I am not sure if this has to come up anyway on Android, like it does with Gamecenter on Apple.

gpgs.players.load({listener = loadLocalPlayerCallback}) does not call the listener function. I don’t know if this has to work to make the following things work:

gpgs.leaderbords.show(“xyz”) does not show the leaderboards, nor does .load trigger the listener function

gpgs.leaderboards.submit() does not submit the score

gpgs.achievements.unlock() does not unlock the achievement

… To sum that up, every gpgs-function despite init and probably login don’t seem to work here… I use 2017.3032.

Here is my working GPGS login code:

local function gpgsLoginListener( event ) print( "Login event:", json.prettify(event) ) end local function gpgsListener( event ) print( "Init event:", json.prettify(event) ) if not event.isError then -- Try to automatically log in the user without displaying the login screen print("Trying to login") gpgs.login({ userInitiated = true, listener = gpgsLoginListener }) end end print("Initializing GPGS") gpgs.init( gpgsListener )

If you do not specify userInitiated = true, it will silently log you in.

Rob

Thanks for the code, this is what it prints out from the loginListener:

I/Corona&nbsp; ( 7984): Login event: { I/Corona&nbsp; ( 7984): &nbsp; "errorCode":8, I/Corona&nbsp; ( 7984): &nbsp; "errorMessage":"internal error", I/Corona&nbsp; ( 7984): &nbsp; "isError":true, I/Corona&nbsp; ( 7984): &nbsp; "name":"login", I/Corona&nbsp; ( 7984): &nbsp; "phase":"logged in" I/Corona&nbsp; ( 7984): }

and everytime I try to do something with GPGS, it prints: W/plugin.gpgs( 9729): Not connected

· · · · · · ·

Following this thread, I activated Drive API and Google Play API for the project and now it finally seems to work. I have to make a few test though, but I think that was the problem.

https://forums.coronalabs.com/topic/66420-gpgs-error-8-internal-error-on-login/

Yep. That error is a configuration error which usually relates to the Drive API.

Rob

I had the issue but my issue is little different,
I had imported gpgs plugin in build, added license in config and init in main.

then i require gpgs and try to login as same as n above steps.

But after the login, the response in as follows:

 Login event:    {
I/Corona  (10503):    “errorCode”:4,
I/Corona  (10503):    “errorMessage”:“sign in required”,
I/Corona  (10503):    “isError”:true,
I/Corona  (10503):    “name”:“login”,
I/Corona  (10503):    “phase”:“logged in”
I/Corona  (10503):  }

i am not getting whats wrong or what is left, I am using the latest daily build 2017.3033.

I have also activated drive api and game services api on console too.

Thanks in Advance.

Are you including:

userInitiated = true

???

Rob

No Rob, It was not there before. I was testing and used a lot of things and fortunately it start working bur was not sure of how? Now with your reply, i am sure it was issue with userInitiated=true. So means we need to add this while login now. Thanks for your quick reaponse.

Hi @philipp3,

If you’re updating these apps, I highly highly recommend that you update your Google Play Games Services code to the new GPGS plugin (not the legacy one). The new one, while technically compatible with legacy code, is vastly better and more complete with many more features that the legacy plugin will never see. It makes sense IMHO to adjust your code to be future-proof using the newer plugin.

https://docs.coronalabs.com/plugin/gpgs/index.html

Best regards,

Brent

Thanks Brent,

I am trying to update an app with gpgs, but the app starts with the Runtime Error:

/User/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:853: module ‘plugin.gpgs’ not found:resource(plugin.gpgs.lu) does not exist in archive

… (and so on)

I think I have completed every step in the documentation, am I missing something?

You probably need to use daily build 3005 or later (recommend 3031 or later).

Rob

Thanks, now init works. But for some reason, the listener function of gpgs.players.load is not called. And I don’t know if I need that for showing the leaderboards, but that doesn’t work for me, too (also not sure if I have to load them first).

local playerName = "player" local function loadLocalPlayerCallback( event ) -- This function is not called if #event.players \> 0 then playerName = event.players[1].name end end local function gameNetworkLoginCallback( event ) gpgs.players.load({listener = loadLocalPlayerCallback}) end local function initCallback( event ) gpgs.login({listener=gameNetworkLoginCallback}) end gpgs.init(initCallback)

local function showNow() &nbsp; &nbsp; gpgs.leaderboards.show() end gpgs.leaderboards.load({listener = showNow})

The first thing I would to is put a print statement in showNow that’s going to print out the values passed in. Secondly gpgs.leaderboards.show() requires a parameter of the leaderboard to show. Finally gpgs.leaderboards.load()'s purpose is to get  you the leaderboard’s data in data form so you can show it however you like.

Try this:

local function showNow() &nbsp; &nbsp; gpgs.leaderboards.show("CgkIltz19SWDJFK13g") &nbsp;--\<------ use your own leaderboard ID from the Google Play developer console. Or leave blank. end showNow()

Of if you really want to use the data version:

local function showNow( event ) print( json.prettify( event ) ) end gpgs.leaderboards.load({listener = showNow})

Now you can look in your console.log and see what data is being returned by gpgs.leaderboards.load().

Rob

Got it, thank you, I will try that tomorrow.

Any idea why the loadLocalPlayerCallback function from the previous post won’t get called?