GPGS worked until I uploaded to Beta

I have been struggling with gpgs for quite awhile… I have finally been able to get it working after coding around a 3 second delay waiting for the listener function to get called (after sending in scores and waiting for a response). 

It all was working as I would like, with apks being loaded directly on my phone.  However, I uploaded the apk to Google Play as a beta, and all those in my testing group cannot see the leaderboards and scores are not being posted. GPGS acts as though it is logging in, but after that, nothing is happening with my leaderboards.

Is there anything special I need to do once the app is uploaded and waiting a move to Production?  Why does it work on my phone, but not after being uploaded?

Show some code  :) .

Also, don’t assume a 3 second delay… it could be shorter, longer, or not at all.

ok, here is the code - and to clarify, this question is not about the delay.  the question is about why everything worked before uploading the apk to the developer console as a beta.  I thought there might be some configuration issue, rather than a coding issue (but I have been wrong before… lots).  thanks for taking a look!

the function to submit the score and the listener:

 -- EXTERNAL LEADERBOARD ---- local function submitScoreListener( event ) print("#17 in the submitScoreListener function - player.lua") -- Google Play Games Services score submission if ( myGlobalData.gpgs ) then -- if not event.isError then --local isBest = nil if ( event.scores["all time"].isNewBest ) then myGlobalData.isleaderboardworthy = "alltime" print("#18 in player submitScoreListener ALLTIME myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) elseif ( event.scores["weekly"].isNewBest ) then myGlobalData.isleaderboardworthy = "weekly" print("#18 in player submitScoreListener WEEKLY myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) elseif ( event.scores["daily"].isNewBest ) then myGlobalData.isleaderboardworthy = "daily" print("#18 in player submitScoreListener DAILY myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) else myGlobalData.isleaderboardworthy = "no high score" print("#18 in player submitScoreListener NO HIGH SCORE myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) end -- Apple Game Center score submission elseif ( myGlobalData.gameCenter ) then if ( event.type == "setHighScore" ) then -- Congratulate player on a high score myGlobalData.isleaderboardworthy = "applehigh" native.showAlert( "Congratulations", "You set a high score!", { "OK" } ) else -- Encourage the player to do better native.showAlert( "Sorry...", "No high score, Better luck next time!", { "OK" } ) end end end local function submitScore( score, mode) print("#4 in the submitScore function") -- manually setting the leaderboard value to trigger response in simulator myGlobalData.isleaderboardworthy = "test value" print("#5 in player submitScore 1 SUBMITSCORE manually set myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) print("#6 in player submitScore 2 last time before the myGlobalData.isleaderboardworthy should set by submitScoreListener") if ( myGlobalData.gpgs ) then -- Submit a score to Google Play Games Services if mode == "reg" then print("#7 in player submitScore 3 - fishing mode - just before submit") myGlobalData.gpgs.leaderboards.submit( { leaderboardId = "myleaderboardID", score = score, listener = submitScoreListener }) elseif mode == "plow" then print("#7 in player submitScore 3 - plow mode - just before submit") myGlobalData.gpgs.leaderboards.submit( { leaderboardId = "myleaderboardID", score = score, listener = submitScoreListener }) end elseif ( myGlobalData.gameCenter ) then -- Submit a score to Apple Game Center if mode == "reg" then myGlobalData.gameCenter.request( "setHighScore", { localPlayerScore = { category = "com.yourdomain.yourgame.leaderboard", value = score }, listener = submitScoreListener }) elseif mode == "plow" then myGlobalData.gameCenter.request( "setHighScore", { localPlayerScore = { category = "com.yourdomain.yourgame.leaderboard", value = score }, listener = submitScoreListener }) end end end 

the button to show the leaderboards

 ----Leaderboard buttons local LB\_Button\_fishing = widget.newButton({ defaultFile = 'images/buttons/leaderboard.png', overFile = 'images/buttons/leaderboard-over.png', width = 45, height = 49, x = halfW + 148, y = 280, x = halfW + 148, y = 280, onRelease = function() print("in the Fishing leaderboard button function") if (myGlobalData.gpgs) then myGlobalData.gpgs.leaderboards.show( "myleaderboardID" ) elseif (myGlobalData.gameCenter) then myGlobalData.gameCenter.show( "leaderboards", { leaderboard = { category = "com.yourdomain.yourgame.leaderboard" } }) end end }) 

from main.lua

myGlobalData.gpgs = nil myGlobalData.gameCenter = nil ------- new local platform = system.getInfo( "platform" ) local env = system.getInfo( "environment" ) local appstore = system.getInfo("targetAppStore") print("Appstore = "..appstore) if (appstore =="google" and env ~= "simulator" ) then myGlobalData.gpgs = require( "plugin.gpgs" ) elseif ( platform == "ios" and env ~= "simulator" ) then myGlobalData.gameCenter = require( "gameNetwork" ) end -- Google Play Games Services initialization/login listener local function gpgsInitListener( event ) if not event.isError then if ( event.name == "init" ) then -- Initialization event -- Attempt to log in the user --native.showAlert( "Init ", "Successful Initiation!", { "OK" } ) myGlobalData.gpgs.login( { userInitiated=true, listener=gpgsInitListener } ) elseif ( event.name == "login" ) then -- Successful login event print( json.prettify(event) ) end end end -- Apple Game Center initialization/login listener local function gcInitListener( event ) if event.data then -- Successful login event print( json.prettify(event) ) end end -- Initialize game network based on platform if ( myGlobalData.gpgs ) then -- Initialize Google Play Games Services print("trying to init gpgs") myGlobalData.gpgs.init( gpgsInitListener ) elseif ( myGlobalData.gameCenter ) then -- Initialize Apple Game Center myGlobalData.gameCenter.init( "gamecenter", gcInitListener ) end

the calls to the show the leader board if there is a highscore 

if params.board == "daily" then print("#17 in the popup:show() with 1 params.board = daily condition") LB\_text:setText ("Today's\nGoogle Play\nhigh score!") LB\_text:setFillColor( 1,1,0) if myGlobalData.plowModeOn =="true" then -- the following should be the onRelease function for the button -- create the button above, set the text, make them visible here, then set the button.onRelease = timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="daily" }); end) else timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="daily" }); end) --myGlobalData.gpgs.leaderboards.show( {leaderboardId="CgkIosnt-ckUEAIQAQ", timeSpan="daily" }) end elseif params.board == "weekly" then print("#17 in the popup:show() with 2 params.board = weekly condition") LB\_text:setText("Google Play\nhigh score of the\nweek!") LB\_text:setFillColor( 1,1,0 ) if myGlobalData.plowModeOn =="true" then timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="weekly"}); end) else timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="weekly"}); end) end elseif params.board == "alltime" then print("#17 in the popup:show() with 3 params.board = alltime condition") LB\_text:setText("Google Play\nALL-TIME\nHigh Score!!") LB\_text:setFillColor( 1,1,0 ) if myGlobalData.plowModeOn =="true" then timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="all time"}); end) else timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="all time"}); end) end elseif params.board == "applehigh" then print("#17 in the popup:show() with 4 params.board = applehigh condition") LB\_text:setText("You made the leaderboard!") LB\_text:setFillColor( 1,1,0 ) if myGlobalData.plowModeOn =="true" then timer.performWithDelay(2500, function() myGlobalData.gameCenter.show( "leaderboards", { leaderboard = { category = "com.yourdomain.yourgame.leaderboard" } }) ;end) else timer.performWithDelay(2500, function() myGlobalData.gameCenter.show( "leaderboards", { leaderboard = { category = "com.yourdomain.yourgame.leaderboard" } }) ;end) end end

I didn’t look at your code, since you said something interesting.

You mentioned it was working in beta, and not production.  I had the same issue (and still do when I update my existing apps recently).  Did you go and enable Google Play and Google Drive APIs in your console?  I did that, and everything started working on it’s own… you may even see these call fails in the adb debug log.

–John

well, not exactly that…

it works when I build and send the apk to my phones via dropbox.  it does not work when I uploaded the same apk to a beta release on the developer console.  I have not yet moved it production because of this issue.

I did enable the apis at one point. Do I need to re-enable them APIs for a beta release?

I took a look at the apis - they were enabled - however, the account in which they were enabled was not linked to the project in may Developer Console.  I linked those accounts from the settings in Dev Console…  I will wait a bit for it to propagate and see if that was the issue.

Let me know if that works… it does sound like the same problem I was experiencing.  If that does not work, we can go through the code a bit.

Show some code  :) .

Also, don’t assume a 3 second delay… it could be shorter, longer, or not at all.

ok, here is the code - and to clarify, this question is not about the delay.  the question is about why everything worked before uploading the apk to the developer console as a beta.  I thought there might be some configuration issue, rather than a coding issue (but I have been wrong before… lots).  thanks for taking a look!

the function to submit the score and the listener:

 -- EXTERNAL LEADERBOARD ---- local function submitScoreListener( event ) print("#17 in the submitScoreListener function - player.lua") -- Google Play Games Services score submission if ( myGlobalData.gpgs ) then -- if not event.isError then --local isBest = nil if ( event.scores["all time"].isNewBest ) then myGlobalData.isleaderboardworthy = "alltime" print("#18 in player submitScoreListener ALLTIME myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) elseif ( event.scores["weekly"].isNewBest ) then myGlobalData.isleaderboardworthy = "weekly" print("#18 in player submitScoreListener WEEKLY myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) elseif ( event.scores["daily"].isNewBest ) then myGlobalData.isleaderboardworthy = "daily" print("#18 in player submitScoreListener DAILY myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) else myGlobalData.isleaderboardworthy = "no high score" print("#18 in player submitScoreListener NO HIGH SCORE myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) end -- Apple Game Center score submission elseif ( myGlobalData.gameCenter ) then if ( event.type == "setHighScore" ) then -- Congratulate player on a high score myGlobalData.isleaderboardworthy = "applehigh" native.showAlert( "Congratulations", "You set a high score!", { "OK" } ) else -- Encourage the player to do better native.showAlert( "Sorry...", "No high score, Better luck next time!", { "OK" } ) end end end local function submitScore( score, mode) print("#4 in the submitScore function") -- manually setting the leaderboard value to trigger response in simulator myGlobalData.isleaderboardworthy = "test value" print("#5 in player submitScore 1 SUBMITSCORE manually set myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) print("#6 in player submitScore 2 last time before the myGlobalData.isleaderboardworthy should set by submitScoreListener") if ( myGlobalData.gpgs ) then -- Submit a score to Google Play Games Services if mode == "reg" then print("#7 in player submitScore 3 - fishing mode - just before submit") myGlobalData.gpgs.leaderboards.submit( { leaderboardId = "myleaderboardID", score = score, listener = submitScoreListener }) elseif mode == "plow" then print("#7 in player submitScore 3 - plow mode - just before submit") myGlobalData.gpgs.leaderboards.submit( { leaderboardId = "myleaderboardID", score = score, listener = submitScoreListener }) end elseif ( myGlobalData.gameCenter ) then -- Submit a score to Apple Game Center if mode == "reg" then myGlobalData.gameCenter.request( "setHighScore", { localPlayerScore = { category = "com.yourdomain.yourgame.leaderboard", value = score }, listener = submitScoreListener }) elseif mode == "plow" then myGlobalData.gameCenter.request( "setHighScore", { localPlayerScore = { category = "com.yourdomain.yourgame.leaderboard", value = score }, listener = submitScoreListener }) end end end 

the button to show the leaderboards

 ----Leaderboard buttons local LB\_Button\_fishing = widget.newButton({ defaultFile = 'images/buttons/leaderboard.png', overFile = 'images/buttons/leaderboard-over.png', width = 45, height = 49, x = halfW + 148, y = 280, x = halfW + 148, y = 280, onRelease = function() print("in the Fishing leaderboard button function") if (myGlobalData.gpgs) then myGlobalData.gpgs.leaderboards.show( "myleaderboardID" ) elseif (myGlobalData.gameCenter) then myGlobalData.gameCenter.show( "leaderboards", { leaderboard = { category = "com.yourdomain.yourgame.leaderboard" } }) end end }) 

from main.lua

myGlobalData.gpgs = nil myGlobalData.gameCenter = nil ------- new local platform = system.getInfo( "platform" ) local env = system.getInfo( "environment" ) local appstore = system.getInfo("targetAppStore") print("Appstore = "..appstore) if (appstore =="google" and env ~= "simulator" ) then myGlobalData.gpgs = require( "plugin.gpgs" ) elseif ( platform == "ios" and env ~= "simulator" ) then myGlobalData.gameCenter = require( "gameNetwork" ) end -- Google Play Games Services initialization/login listener local function gpgsInitListener( event ) if not event.isError then if ( event.name == "init" ) then -- Initialization event -- Attempt to log in the user --native.showAlert( "Init ", "Successful Initiation!", { "OK" } ) myGlobalData.gpgs.login( { userInitiated=true, listener=gpgsInitListener } ) elseif ( event.name == "login" ) then -- Successful login event print( json.prettify(event) ) end end end -- Apple Game Center initialization/login listener local function gcInitListener( event ) if event.data then -- Successful login event print( json.prettify(event) ) end end -- Initialize game network based on platform if ( myGlobalData.gpgs ) then -- Initialize Google Play Games Services print("trying to init gpgs") myGlobalData.gpgs.init( gpgsInitListener ) elseif ( myGlobalData.gameCenter ) then -- Initialize Apple Game Center myGlobalData.gameCenter.init( "gamecenter", gcInitListener ) end

the calls to the show the leader board if there is a highscore 

if params.board == "daily" then print("#17 in the popup:show() with 1 params.board = daily condition") LB\_text:setText ("Today's\nGoogle Play\nhigh score!") LB\_text:setFillColor( 1,1,0) if myGlobalData.plowModeOn =="true" then -- the following should be the onRelease function for the button -- create the button above, set the text, make them visible here, then set the button.onRelease = timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="daily" }); end) else timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="daily" }); end) --myGlobalData.gpgs.leaderboards.show( {leaderboardId="CgkIosnt-ckUEAIQAQ", timeSpan="daily" }) end elseif params.board == "weekly" then print("#17 in the popup:show() with 2 params.board = weekly condition") LB\_text:setText("Google Play\nhigh score of the\nweek!") LB\_text:setFillColor( 1,1,0 ) if myGlobalData.plowModeOn =="true" then timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="weekly"}); end) else timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="weekly"}); end) end elseif params.board == "alltime" then print("#17 in the popup:show() with 3 params.board = alltime condition") LB\_text:setText("Google Play\nALL-TIME\nHigh Score!!") LB\_text:setFillColor( 1,1,0 ) if myGlobalData.plowModeOn =="true" then timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="all time"}); end) else timer.performWithDelay(2500, function() myGlobalData.gpgs.leaderboards.show( {leaderboardId="myleaderboardID", timeSpan="all time"}); end) end elseif params.board == "applehigh" then print("#17 in the popup:show() with 4 params.board = applehigh condition") LB\_text:setText("You made the leaderboard!") LB\_text:setFillColor( 1,1,0 ) if myGlobalData.plowModeOn =="true" then timer.performWithDelay(2500, function() myGlobalData.gameCenter.show( "leaderboards", { leaderboard = { category = "com.yourdomain.yourgame.leaderboard" } }) ;end) else timer.performWithDelay(2500, function() myGlobalData.gameCenter.show( "leaderboards", { leaderboard = { category = "com.yourdomain.yourgame.leaderboard" } }) ;end) end end

I didn’t look at your code, since you said something interesting.

You mentioned it was working in beta, and not production.  I had the same issue (and still do when I update my existing apps recently).  Did you go and enable Google Play and Google Drive APIs in your console?  I did that, and everything started working on it’s own… you may even see these call fails in the adb debug log.

–John

well, not exactly that…

it works when I build and send the apk to my phones via dropbox.  it does not work when I uploaded the same apk to a beta release on the developer console.  I have not yet moved it production because of this issue.

I did enable the apis at one point. Do I need to re-enable them APIs for a beta release?

I took a look at the apis - they were enabled - however, the account in which they were enabled was not linked to the project in may Developer Console.  I linked those accounts from the settings in Dev Console…  I will wait a bit for it to propagate and see if that was the issue.

Let me know if that works… it does sound like the same problem I was experiencing.  If that does not work, we can go through the code a bit.