Not connected GPGS v2

Hi!

I’ve been struggling with this for a few days now to no avail. I’ll post the code below but in short I’m following the tutorial found in the docs. When I’m later trying to show the leaderboards or submit a score to said leaderboards I get an error in the terminal saying that gpgs are not connected despite a successful login at launch. Is there something I’m missing with the new V2 pluggin?

local globalData = require( "globalData" ) local json = require( "json" ) globalData.gpgs = nil local platform = system.getInfo( "platform" ) local env = system.getInfo( "environment" ) if ( platform == "android" and env ~= "simulator" ) then globalData.gpgs = require( "plugin.gpgs.v2" ) end local function gpgsInitListener( event ) if not event.isError then if ( event.name == "init" ) then -- Initialization event -- Attempt to log in the user print( json.prettify(event) ) elseif ( event.name == "login" ) then -- Successful login event print( json.prettify(event) ) end end end if ( globalData.gpgs ) then -- Initialize Google Play Games Services globalData.gpgs.login( { userInitiated=true, listener=gpgsInitListener } ) end

sometime later:

function showLeaderBoards() print("leader") if ( globalData.gpgs ) then          globalData.gpgs.leaderboards.show()                  print( json.prettify(event) )         end end cupPress:addEventListener( "tap", showLeaderBoards)

Here I get the gpgs: not connected error.

Any help would be much appreciated! :slight_smile:

I’m also having the same problem but some people say their problems are solved when they manually activate the following APIs: Drive API and Google Play Developer API.

If you enabled those, you are probably having the same issue as me. No errors thrown, event.phase is “logged in” but the player is neither connected nor authenticated.

As a test, I would remove the check for event.isError to see if you can connect.

I tend to use isConnected() when I attempt a GPGS call.

Same here.

The weird thing is I’m sharing a big part of the code in 4 different games.

The one game connects and shows leaderboard as it should, the other three won’t. With the same code.

I’m not using the isConnected parameter but it shouldn’t be a problem since my first game actually connects.

Using release keystore.

I’ve enabled all the necessary APIs.

Double and triple checked my authentication parameters.

Tried with latest public build and two fifferent daily builds.

I can see on adb logcat the “logged in” event but when I call leaderboards.show I get “plugin.gpgs. not connected”.

One thing I find weird is that in the first game that leaderboards do work, abd logcat gives me two “logged in” events in a row.

But the other three games that leaderboards don’t work, I only get one “logeed in” event.

Well, I’ve been trying to get this to work for 2 days now with no success. Has anyone else resolved this?  :wacko:

Still struggling, looking at the requests received by the drive api they all result in errors.

I wish I had an answer for you. This is working as expected in my game. I wish Google didn’t make setting things up so difficult. I’m going to post the settings for my game along with some notes:

First my build.settings “android” section:

 android = { googlePlayGamesAppId = "249XXXXXXX34", -- this has to match what is online facebookAppId = "16XXXXXXXXXXXX61", usesPermissions = { "com.android.vending.BILLING", "com.android.vending.CHECK\_LICENSE", "android.permission.INTERNET", "android.permission.VIBRATE", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.ACCESS\_NETWORK\_STATE", -- needed for the vungle plugin }, supportsScreens = { resizeableActivity = false, smallScreens = true, normalScreens = true, largeScreens = true, xlargeScreens = true, }, },

Go to the Game Services tab and find your game there:

Click on your game to get the value for googlePlayGamesAppId. Even though it looks like a number, make it a string!

Scroll to the bottom and make sure you have green checkmarks here:

Check on the linked app section and make sure your real game is linked. Both are likely sharing similar names.

Make sure you have a leaderboard added and published.

Finally, make sure you have no “triangle” “todo” logos here:

Then follow the tutorial on adding leaderboards to your app. My code will be a little different than the tutorial (but the tutorial was based on this and made more generic).

myData.gpgs = nil print("platform: ", myData.platform, system.getInfo("environment")) if "android" == myData.platform and "simulator" ~= system.getInfo("environment") then print("requiring GPGS") myData.gpgs = require("plugin.gpgs.v2") end local function gpgsLoginListener( event ) print("\*\*\* gpgsLoginListener \*\*\*") print( json.prettify( event ) ) if not event.isError then if ( event.name == "login" ) then -- Successful login event myData.isGameNetworkingLoggedIn = true print("I think isConnected() is", myData.gpgs.isConnected()) end end end if myData.gpgs then print("Initializing GPGS") --myData.gpgs.init( gpgsInitListener ) myData.gpgs.login( { userInitiated=true, listener=gpgsLoginListener } ) end

For testing purposes, I added a button to my UI to set a high score. It’s hard to test this through normal game play because getting a new high score is tough.

 local function gcSubmitScoreListener() print("submitted") end local gpgsSetHighScoreButton = widget.newButton({ label = "Set High Score", onRelease = function( event ) myData.settings.highScore = myData.settings.highScore + 100000 myData.gpgs.leaderboards.submit({ leaderboardId = "CgkXXXXXXXXXXXXQBg", score = myData.settings.highScore, listener = gcSubmitScoreListener } ) end, }) sceneGroup:insert(gpgsSetHighScoreButton) gpgsSetHighScoreButton.x = display.contentWidth - 50 gpgsSetHighScoreButton.y = display.contentHeight - 20

Then to show the score:
 

local function gameNetworkingLeaderboards() print("\*\*\* gameNetworking leaderboards \*\*\*") if myData.gameNetwork then print("\*\*\* gameNetwork: attempting to call show leaderboard") myData.gameNetwork.show( "leaderboards", { leaderboard = { category = "com.myawesomegame.leaderboard" }, listener = showLeaders }) elseif myData.gameCenter then print("\*\*\* gameCenter leaderboards") myData.gameCenter.leaderboards.show("com.myawesomegame.leaderboard") elseif myData.gpgs then print("\*\*\* GPGS trying to show GPGS leaderboard", myData.gpgs.isConnected()) myData.gpgs.leaderboards.show( ) end end

This works for me. Did I get everything above? Who knows. Google keeps changing things and making it hard to find all the settings.

Can you copy/paste this code? Not a chance because you’re likely not using the same faux globals table I’m using. My ID’s have been masked. You likely have named functions differently.

But this works.

Thanks for the answer! I’ll go through my game again to make sure it’s all setup correctly and hopefully I’ll be able to solve it.

What’s odd though is that the code I’m using now works for another game that I published a while back. Was the application above built recently? I’m curious to see if it works if you build a new application now, if it’s not too much trouble of course. If it still works after that then it should be something wrong on my end.  :wacko:

I published the leaderboard but it still fails. I guess I’ll try a different solution.

Administrative note: Please don’t quote whole messages when they are particularly long or has images.

Thanks

Rob

Sorry that I forgot to mention some details.

1- APIs required part doesn’t show me to enable Drive API but I enabled it anyway. Even though it’s enabled and not required for simple login to work, I still get errors for Drive API on the console. I’m assuming pinging Drive API is a plugin thing but I’m not sure if it’s related to the problem we’re having.

2- I’m not sure if it’s a Google thing or a plugin thing but we shouldn’t be seeing the “logged in” phase when GPGS is not connected nor authenticated. We should be seeing a “login fail” state or an event error with an error message to why it failed but the event returns no errors with a “logged in” flag even though we’re not.

I’ve been restarting from scratch a few times now setting up the game in the play console and so on. Still no success, is it possible to use the old plugin gpgs (v1)? When I try to use the old plugin the game crashes on launch unfortunately.

I really need to get this update pushed soon if possible  :slight_smile:

You can try and use the old plugin, but it’s dependent on the Google Plus login scope.

Rob

No Rob, i’m afraid old plugin is not working, it always receives “8 internal error” even though i’m using same code than other game which is working with old plugin, that was my reason to move to gpgs.v2 plugin but also i’m receiving a gpgs.v2 “not connected” in adb.

Days and days debugging and trying workarounds and there is no way of use gpgs on a game, maybe because it doesn’t depend on us… but it’s awful.

Me too, could this be the reason of “not connected” error?

For all you to know, i removed my linked app from the game services that i was trying to connect and i have linked it to a game in my game services that i was using (and working) and just changing the googlePlayGamesAppId in my build settings … it works (with gpgs v1). 

I did the same change as gorosoft above and it worked for me too. Using gpgs.v2 in my case.

But unfortunately this can not be considered as a permanent solution.

Now that the leaderboard does open, but it gives you the choice to open all the leaderboards of the other linked games.

So if i have 10 linked games and use this method to finally get the leaderboards working, I will end up with a player who wants to check his standing but instead gets frustrated from having to find the right board from the list.

It will be confusing and ultimately cause the player to see it as a disturbance.

In general I am very dissapointed.

I have 6 android studio apps all working fine.

2 unity apps working fine as well.

I only face this issue with corona and no matter what I do there is no solution, since it doesn’t seem to be a problem with corona.

I hope someone comes up with an idea before I give it up because I am very close to that point.

I already gave up and trying some php/mySQL solution to setup my own leaderboard at the moment because it seems that Corona doesn’t have any plans to look into this in the near future. That’s what I got from Rob’s answers above. I’d advice you follow the same route.

By the way, I don’t think GPGS v1 can be considered a reliable solution because, as far as I can remember, people were reporting many ANRs and crashes related to that version.

That’s not quite 100% correct. I’m trying to build a fresh app that uses the GPGSv2 plugin to see if I can find the trigger as to why some apps work and others do not.

Now that said, I believe GPGS has a REST API and if you’re just wanting leaderboards, it might be a simpler approach. But I am trying to track down the difference.

Rob

@Rob

I am getting some errors in isAuthenticated() method of gpgs v2. Here is the linkto the full error report. This error happen when in the user is logged out and any gpgs calls gives runtime error.  :frowning: