GPGS leaderboards are not showing

gpgs = require( "plugin.gpgs" ) function gpgsLoginListener( event ) gpgsData.userPref = event.phase end function gpgsInitListener( event ) if not event.isError then -- Try to automatically log in the user with displaying the login screen if (gpgsData.userPref == "logged in") then gpgs.login( { listener = gpgsLoginListener } ) elseif (gpgsData.userPref == "logged out") then -- DO NOTHING end end end gpgs.init( gpgsInitListener ) gpgs.setPopupPosition( "TopCenter" ) gpgs.isConnected()

I initialize gpgs like this, and then I try to view existing leaderboard with

gpgs.leaderboards.show({leaderboardId = "CgkI4fD7z6MDEAIQAA"})

But it doesn’t show anything on screen.

Ids of application matches, Id of leaderboard matches, everything matches, but leaderboard is not showing

Are there any messages in your device’s console log that could indicate what’s going on?

Rob

If you tell me how I can enable Corona Console on my Android device, It will be nice. On simulator gpgs are not working at all, it says (GPGS are not supported on this platform (I use Windows))

Nevermind, but there is absolutely nothing in console logs. There is just nothing happens when I press button, which must show leaderboard

Please see this guide on debugging:  https://docs.coronalabs.com/guide/basics/debugging/index.html

The problem that many people run into is they filter the “adb logcat” output by filtering on strings originating from your Corona App. However things like Google Play Game Services is running in the Google Play app and when you apply that filter, you miss important messages from other intents.

Just run “adb logcat” with no extra parameters. It will dump a lot of useless information at you, but there should be something useful in there.

Rob

Is there anywhere pieces of code on how to implement the gpgs in my game ? I am having trouble with it also and my problem is that you cannot find a lot of documentation on how to use it in Corona.

I think Corona Labs should do a tutorial for it 

Hello!

We are currently having the same problem, so were you able to solve the problem?

Just published yesterday! Hot off the press: https://docs.coronalabs.com/tutorial/games/gameLeaderboards/index.html

Rob

We followed the tutorial, which Rob just posted. But the leaderboards still don`t show. We run the adb logcat and we got this message:

ConfigFileUtils: Failed to read config file: /data/data/com.google.android.gms/app_chimera/current_modulesets.pb: open failed: ENOENT (No such file or directory)

Here is our main.lua:

local composer = require( "composer" ) display.setStatusBar( display.HiddenStatusBar ) native.setProperty( "androidSystemUiVisibility", "immersive" ) -- Code to initialize your app local loadsave = require("loadsave") local licensing = require( "licensing" )licensing.init( "google" ) local function licensingListener( event ) if not ( event.isVerified ) then -- Failed to verify app from the Google Play store; print a message local function onComplete( event ) if ( event.action == "clicked" ) then local i = event.index if ( i == 1 ) then -- Do nothing; dialog will simply dismiss native.requestExit() end end end native.showAlert( "Error:", "Please download this app from Google Play", { "OK" }, onComplete ) end end licensing.verify( licensingListener ) --muista build.settings!!!!!!!!!!!!!! -- Assumes that "scene1.lua" exists and is configured as a Composer scene local gpgs = require( "plugin.gpgs" ) local gpgsData local json = require( "json" ) gpgsData = loadsave.loadTable( "gpgsData.json" ) if ( gpgsData == nil ) then gpgsData = {} gpgsData.firstTime = true loadsave.saveTable( gpgsData, "gpgsData.json" ) end -- gpgsData nil conditional END local function gpgsInitListener( event ) if not event.isError then if ( event.name == "init" ) then -- Initialization event -- Attempt to log in the user if (gpgsData.firstTime == true) then gpgs.login( { userInitiated=true, listener=gpgsInitListener } ) gpgsData.firstTime = false loadsave.saveTable( gpgsData, "gpgsData.json" ) else gpgs.login( { listener=gpgsInitListener } ) end elseif ( event.name == "login" ) then -- Successful login event print( json.prettify(event) ) end end end gpgs.init( gpgsInitListener ) composer.gotoScene( "menu" )

here is our menu.lua where the leaderboards should show:

if ( phase == "will" ) then -- Code here runs when the scene is still off screen (but is about to come on screen) local widget = require( "widget" ) local gpgs = require( "plugin.gpgs" ) local loadsave = require("loadsave") local json = require( "json" ) local gpgsData local function submitScoreListener( event ) -- Google Play Games Services score submission if not event.isError then local isBest = nil if ( event.scores["daily"].isNewBest ) then isBest = "a daily" elseif ( event.scores["weekly"].isNewBest ) then isBest = "a weekly" elseif ( event.scores["all time"].isNewBest ) then isBest = "an all time" end if isBest then -- Congratulate player on a high score local message = "You set " .. isBest .. " high score!" native.showAlert( "Congratulations", message, { "OK" } ) print("moi") else -- Encourage the player to do better native.showAlert( "Sorry...", "Better luck next time!", { "OK" } ) end end end local function submitScore( score ) -- Submit a score to Google Play Games Services gpgs.leaderboards.submit( { leaderboardId = "CgkI5bWMz4wFEAIQAQ", score = score, listener = submitScoreListener }) end submitScore(10) local function showLeaderboards(event) if event.phase == "ended" then gpgs.leaderboards.show("CgkI5bWMz4wFEAIQAQ") end end local function gotoBuild(event) if event.phase == "ended" then end end local menuText = display.newText("MENU", display.contentCenterX, display.contentCenterY- 120, native.systemFrontBold, 50) local playButton = widget.newButton( { left = display.viewableContentWidth/2 - 80, top = display.viewableContentHeight/2 - 90, width = 160, height = 100, defaultFile = "images/buttons/Reset.png", onEvent = showLeaderboards } ) local buildButton = widget.newButton( { left = display.viewableContentWidth/2 - 80, top = display.viewableContentHeight/2 + 20, width = 160, height = 100, defaultFile = "images/buttons/Reset.png", onEvent = gotoBuild } ) elseif ( phase == "did" ) then -- Code here runs when the scene is entirely on screen end

Are you running “adb logcat” with any additional parameters?

No, so I saw the google messages also.

Are you 100% sure the user is logged in by the time you try to submit a score? Are you getting such confirmation from your “gpgsInitListener()” function"?

Brent

Hi! we may have found the error:

 07-29 11:14:13.628 23650 23694 I LicenseChecker: Received response. 07-29 11:14:13.628 23650 23694 I LicenseChecker: Clearing timeout. 07-29 11:14:13.658 4899 5471 W Auth : [GetToken] GetToken failed with status code: UNREGISTERED\_ON\_API\_CONSOLE 07-29 11:14:13.660 12705 13131 E TokenRequestor: You have wrong OAuth2 related configurations, please check. Detailed error: UNREGISTERED\_ON\_API\_CONSOLE 07-29 11:14:13.669 12705 13281 W GamesServiceBroker: Client connected with SDK 11411000, Services 11302448, and Games 52250048

this is from the adb logcat.

The problem is solved! The problem was with the oAuth client and enabled APIs. Thanks for your help!

Are there any messages in your device’s console log that could indicate what’s going on?

Rob

If you tell me how I can enable Corona Console on my Android device, It will be nice. On simulator gpgs are not working at all, it says (GPGS are not supported on this platform (I use Windows))

Nevermind, but there is absolutely nothing in console logs. There is just nothing happens when I press button, which must show leaderboard

Please see this guide on debugging:  https://docs.coronalabs.com/guide/basics/debugging/index.html

The problem that many people run into is they filter the “adb logcat” output by filtering on strings originating from your Corona App. However things like Google Play Game Services is running in the Google Play app and when you apply that filter, you miss important messages from other intents.

Just run “adb logcat” with no extra parameters. It will dump a lot of useless information at you, but there should be something useful in there.

Rob

Is there anywhere pieces of code on how to implement the gpgs in my game ? I am having trouble with it also and my problem is that you cannot find a lot of documentation on how to use it in Corona.

I think Corona Labs should do a tutorial for it 

Hello!

We are currently having the same problem, so were you able to solve the problem?