Google Play Game Services - Sign In Error

Hi, I’ve setup GPGS in my console and implemented the API into my code using the tutorial, triple checked everything and now as I’m testing it on my device, it’s asking me to login twice… and then it gives me a “Sign-In Error” message after the second alert.

I have also tried the sample found here: https://github.com/coronalabs/plugins-sample-gameNetwork-google

and amended the ID to my own but it’s giving me the same error.

Using latest public release.

bff11bd7791f2fa93be17032c1c6bae6.png

Any help is much appreciated.

Can you post your code where you’re managing your login process, perhaps your whole main.lua?   Also are you getting any errors in your console log on your device?  If you don’t know how to get that information read this blog:

http://www.coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

I didn’t get any errors in the console, but strangely enough it’s logging in just fine now… Thanks anyway  :slight_smile:

Okay so I may have deleted the API in my Google API Console and then the game services disappeared from my Dev Console BUT I undeleted it and everything has been restored(I had to remake the game services), but now it’s giving me the double sign-in error again using the Corona Sample and my app is giving a

“The gameNetwork is not available on this platform” message when attempting to show leaderboards/acheivements.
 
My app is not asking for sign-in with either debug or release key. Does “Target Store:” change anything? I tried both Google Play and “None” with no success.

I’m also getting a “WARNING: licensing.init() was already called for google.” error in the console.

Main.lua:

[lua]local licensing = require( “licensing” )
licensing.init( “google” )

local function licensingListener( event )

local verified = event.isVerified
if not event.isVerified then
–failed verify app from the play store, we print a message
–local alertBox = native.showAlert( “Notice”,
–“This app is not licensed!”,
–{“Purchase”, “Cancel”}, buyApp )
–native.requestExit() --assuming this is how we handle pirates
end
end

licensing.verify( licensingListener )

local function buyApp( event )
if “clicked” == event.action then
local i = event.index
if 1 == i then
system.openURL( “http://play.google.com/store/(ID)” )
elseif 2 == i then
– Close popup

end
end
end


–SETTINGS(internal)

– Hide Status Bar
display.setStatusBar(display.HiddenStatusBar)


– LIBRARIES – load global libraries that will be used throughout the app

local storyboard = require “storyboard”

storyboard.purgeOnSceneChange = true
–storyboard.isDebug = true

settings = require(“settings”)
settings.load()


– Scene Calls --go to’s

storyboard.gotoScene( ‘menu’ )[/lua]

Menu.lua:

[lua]local storyboard = require(“storyboard”)
local scene = storyboard.newScene()

local GGData = require( “GGData” )
coinbox = GGData:new(‘coins’)

coinbox:setSync( true )

local crypto = require( “crypto” )
coinbox:enableIntegrityControl( crypto.sha512, “” )
coinbox:updateAllIntegrityHashes()
local corruptEntries = coinbox:verifyIntegrity()
–print( corruptEntries ) – How many, if any, values were removed due to being different than expected.

local gameNetwork = require(“gameNetwork”)
local playerName


–DEFINE VARIABLES

local options
local mainMenu
local mrect1
local mrect2
local mrect3
local mrect4
local mrect5

local ox, oy = math.abs(display.screenOriginX), math.abs(display.screenOriginY)

–Functions
local levelSelect
local helpMenu
local appList

options =
{
effect = “crossFade”,
time = 1000
}


– Main Functions

–Game code
–(Note to self) X=Left/Right, Y=Up/Down | Left = -, Right = +, | Up = -, Down = +

levelSelect = function()
storyboard.gotoScene(‘levelselect’)
end

helpMenu = function()
storyboard.gotoScene(‘help’)
end

local function showLeaderboards( event )
–if ( system.getInfo(“platformName”) == “Android” ) then
gameNetwork.show( “leaderboards” )
–else
–gameNetwork.show( “leaderboards”, { leaderboard = {timeScope=“AllTime”} } )
– end
return true
end

local function showAchievements( event )
gameNetwork.show( “achievements” )
return true
end

function appRun()
if (settings.get(‘timesRun’)) == nil then
timesRun = 1
–print (“Saving Times Run “…timesRun…” to settings.json”)
settings.set(‘timesRun’, timesRun)
–print (" Times Run is:"…(settings.get(‘timesRun’))…" from settings.json")
GGData:set(‘coins’, 0)
coinbox:save()
else

end

end

delayListeners = function()
mrect1:addEventListener(‘touch’, levelSelect )
mrect2:addEventListener(‘touch’, helpMenu )
mrect3:addEventListener(‘touch’, appList )
mrect4:addEventListener(‘touch’, showAchievements )
mrect5:addEventListener(‘touch’, showLeaderboards )
end


– Scenes

– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view
mainMenu = display.newImage(‘images/mainmenu.png’)

mrect1 = display.newRect(30, 181, 94, 34)
mrect1.isVisible = false
mrect1.isHitTestable = true

mrect2 = display.newRect(30, 254, 96, 36)
mrect2.isVisible = false
mrect2.isHitTestable = true

mrect3 = display.newRect(13, 8, 129, 8)
mrect3.isVisible = false
mrect3.isHitTestable = true

mrect4 = display.newRect(31, 113, 111, 16)
mrect4.isVisible = true
mrect4.alpha = 0.5
mrect4.isHitTestable = true

mrect5 = display.newRect(175, 113, 111, 16)
mrect5.isVisible = true
mrect5.alpha = 0.5
mrect5.isHitTestable = true

group:insert(mrect1)
group:insert(mrect2)
group:insert(mrect3)
group:insert(mrect4)
group:insert(mrect5)
group:insert(mainMenu)

local Theme = audio.loadStream( “Title Screen Music.mp3” )
local Themeplay = audio.play( Theme, {loops=-1})

GGData:get(‘coins’)
end

– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view

mrect1:addEventListener(‘touch’, levelSelect )
mrect2:addEventListener(‘touch’, helpMenu )
mrect3:addEventListener(‘touch’, appList )
mrect4:addEventListener(‘touch’, showAchievements )
mrect5:addEventListener(‘touch’, showLeaderboards )

–timer.performWithDelay(400, delayListeners)
appRun()

local function showCoins()
coinTxt = display.newText((coinbox.coins), 230, 5.5 - oy, “absender”, 15)
coinTxt.xScale = 5
coinTxt.yScale = 5
coinTxt.alpha = 0
coinTxt:setReferencePoint(display.CenterLeftReferencePoint)
group:insert(coinTxt)
transition.to(coinTxt, {alpha=1, xScale=1, yScale=1, delay=500})
end
timer.performWithDelay( 300, showCoins )
end

– Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view

Runtime:removeEventListener( “system”, systemEvents )
audio.stop()

end

– Called prior to the removal of scene’s “view” (display group)
function scene:destroyScene( event )
local group = self.view

audio.dispose( Theme )
Theme = nil

end


– Google Play Game Services Implementation

local function loadLocalPlayerCallback( event )
playerName = event.data.alias
–saveSettings() --save player data locally using your own “saveSettings()” function
end

local function gameNetworkLoginCallback( event )
gameNetwork.request( “loadLocalPlayer”, { listener=loadLocalPlayerCallback } )
return true
end

local function gpgsInitCallback( event )
gameNetwork.request( “login”, { userInitiated=true } )
print(‘Logging in…’)
end

local function gameNetworkSetup()
–if ( system.getInfo(“platformName”) == “Android” ) then
gameNetwork.init( “google”, gpgsInitCallback )
–else
– gameNetwork.init( “gamecenter”, gameNetworkLoginCallback )
–end
end

------HANDLE SYSTEM EVENTS------
local function systemEvents( event )
print("systemEvent " … event.type)
if ( event.type == “applicationStart” ) then
gameNetworkSetup() --login to the network here
end
return true
end

Runtime:addEventListener( “system”, systemEvents )


– Scene listeners

scene:addEventListener(“createScene”, scene)

scene:addEventListener(“enterScene”, scene)

scene:addEventListener(“exitScene”, scene)

scene:addEventListener(“destroyScene”, scene)

return scene[/lua]

I’ve also tried commenting out the licensing stuff to no avail… I’m not sure what else I can try.

Hi @TwinTails,

This is most likely an issue in how you’ve set up Storyboard, its scope, and how you’re calling things in the Storyboard module(s). I recommend that you start with this video tutorial on Storyboard’s core functionality:

http://www.coronalabs.com/blog/2013/08/20/tutorial-reloading-storyboard-scenes/

Best regards,

Brent

Hello Brent,

I watched the video and moved my code (licensing+gpgs) inside my menu.lua “enterScene” function and then I got the login popup(success!) but it gave me the Sign-in error again like the sample.

Anyway, I did some searching and found the idea to re-link my package in the Dev Console and it’s working again! Thanks for the help :slight_smile:

-TT

Can you post your code where you’re managing your login process, perhaps your whole main.lua?   Also are you getting any errors in your console log on your device?  If you don’t know how to get that information read this blog:

http://www.coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

I didn’t get any errors in the console, but strangely enough it’s logging in just fine now… Thanks anyway  :slight_smile:

Okay so I may have deleted the API in my Google API Console and then the game services disappeared from my Dev Console BUT I undeleted it and everything has been restored(I had to remake the game services), but now it’s giving me the double sign-in error again using the Corona Sample and my app is giving a

“The gameNetwork is not available on this platform” message when attempting to show leaderboards/acheivements.
 
My app is not asking for sign-in with either debug or release key. Does “Target Store:” change anything? I tried both Google Play and “None” with no success.

I’m also getting a “WARNING: licensing.init() was already called for google.” error in the console.

Main.lua:

[lua]local licensing = require( “licensing” )
licensing.init( “google” )

local function licensingListener( event )

local verified = event.isVerified
if not event.isVerified then
–failed verify app from the play store, we print a message
–local alertBox = native.showAlert( “Notice”,
–“This app is not licensed!”,
–{“Purchase”, “Cancel”}, buyApp )
–native.requestExit() --assuming this is how we handle pirates
end
end

licensing.verify( licensingListener )

local function buyApp( event )
if “clicked” == event.action then
local i = event.index
if 1 == i then
system.openURL( “http://play.google.com/store/(ID)” )
elseif 2 == i then
– Close popup

end
end
end


–SETTINGS(internal)

– Hide Status Bar
display.setStatusBar(display.HiddenStatusBar)


– LIBRARIES – load global libraries that will be used throughout the app

local storyboard = require “storyboard”

storyboard.purgeOnSceneChange = true
–storyboard.isDebug = true

settings = require(“settings”)
settings.load()


– Scene Calls --go to’s

storyboard.gotoScene( ‘menu’ )[/lua]

Menu.lua:

[lua]local storyboard = require(“storyboard”)
local scene = storyboard.newScene()

local GGData = require( “GGData” )
coinbox = GGData:new(‘coins’)

coinbox:setSync( true )

local crypto = require( “crypto” )
coinbox:enableIntegrityControl( crypto.sha512, “” )
coinbox:updateAllIntegrityHashes()
local corruptEntries = coinbox:verifyIntegrity()
–print( corruptEntries ) – How many, if any, values were removed due to being different than expected.

local gameNetwork = require(“gameNetwork”)
local playerName


–DEFINE VARIABLES

local options
local mainMenu
local mrect1
local mrect2
local mrect3
local mrect4
local mrect5

local ox, oy = math.abs(display.screenOriginX), math.abs(display.screenOriginY)

–Functions
local levelSelect
local helpMenu
local appList

options =
{
effect = “crossFade”,
time = 1000
}


– Main Functions

–Game code
–(Note to self) X=Left/Right, Y=Up/Down | Left = -, Right = +, | Up = -, Down = +

levelSelect = function()
storyboard.gotoScene(‘levelselect’)
end

helpMenu = function()
storyboard.gotoScene(‘help’)
end

local function showLeaderboards( event )
–if ( system.getInfo(“platformName”) == “Android” ) then
gameNetwork.show( “leaderboards” )
–else
–gameNetwork.show( “leaderboards”, { leaderboard = {timeScope=“AllTime”} } )
– end
return true
end

local function showAchievements( event )
gameNetwork.show( “achievements” )
return true
end

function appRun()
if (settings.get(‘timesRun’)) == nil then
timesRun = 1
–print (“Saving Times Run “…timesRun…” to settings.json”)
settings.set(‘timesRun’, timesRun)
–print (" Times Run is:"…(settings.get(‘timesRun’))…" from settings.json")
GGData:set(‘coins’, 0)
coinbox:save()
else

end

end

delayListeners = function()
mrect1:addEventListener(‘touch’, levelSelect )
mrect2:addEventListener(‘touch’, helpMenu )
mrect3:addEventListener(‘touch’, appList )
mrect4:addEventListener(‘touch’, showAchievements )
mrect5:addEventListener(‘touch’, showLeaderboards )
end


– Scenes

– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view
mainMenu = display.newImage(‘images/mainmenu.png’)

mrect1 = display.newRect(30, 181, 94, 34)
mrect1.isVisible = false
mrect1.isHitTestable = true

mrect2 = display.newRect(30, 254, 96, 36)
mrect2.isVisible = false
mrect2.isHitTestable = true

mrect3 = display.newRect(13, 8, 129, 8)
mrect3.isVisible = false
mrect3.isHitTestable = true

mrect4 = display.newRect(31, 113, 111, 16)
mrect4.isVisible = true
mrect4.alpha = 0.5
mrect4.isHitTestable = true

mrect5 = display.newRect(175, 113, 111, 16)
mrect5.isVisible = true
mrect5.alpha = 0.5
mrect5.isHitTestable = true

group:insert(mrect1)
group:insert(mrect2)
group:insert(mrect3)
group:insert(mrect4)
group:insert(mrect5)
group:insert(mainMenu)

local Theme = audio.loadStream( “Title Screen Music.mp3” )
local Themeplay = audio.play( Theme, {loops=-1})

GGData:get(‘coins’)
end

– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view

mrect1:addEventListener(‘touch’, levelSelect )
mrect2:addEventListener(‘touch’, helpMenu )
mrect3:addEventListener(‘touch’, appList )
mrect4:addEventListener(‘touch’, showAchievements )
mrect5:addEventListener(‘touch’, showLeaderboards )

–timer.performWithDelay(400, delayListeners)
appRun()

local function showCoins()
coinTxt = display.newText((coinbox.coins), 230, 5.5 - oy, “absender”, 15)
coinTxt.xScale = 5
coinTxt.yScale = 5
coinTxt.alpha = 0
coinTxt:setReferencePoint(display.CenterLeftReferencePoint)
group:insert(coinTxt)
transition.to(coinTxt, {alpha=1, xScale=1, yScale=1, delay=500})
end
timer.performWithDelay( 300, showCoins )
end

– Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view

Runtime:removeEventListener( “system”, systemEvents )
audio.stop()

end

– Called prior to the removal of scene’s “view” (display group)
function scene:destroyScene( event )
local group = self.view

audio.dispose( Theme )
Theme = nil

end


– Google Play Game Services Implementation

local function loadLocalPlayerCallback( event )
playerName = event.data.alias
–saveSettings() --save player data locally using your own “saveSettings()” function
end

local function gameNetworkLoginCallback( event )
gameNetwork.request( “loadLocalPlayer”, { listener=loadLocalPlayerCallback } )
return true
end

local function gpgsInitCallback( event )
gameNetwork.request( “login”, { userInitiated=true } )
print(‘Logging in…’)
end

local function gameNetworkSetup()
–if ( system.getInfo(“platformName”) == “Android” ) then
gameNetwork.init( “google”, gpgsInitCallback )
–else
– gameNetwork.init( “gamecenter”, gameNetworkLoginCallback )
–end
end

------HANDLE SYSTEM EVENTS------
local function systemEvents( event )
print("systemEvent " … event.type)
if ( event.type == “applicationStart” ) then
gameNetworkSetup() --login to the network here
end
return true
end

Runtime:addEventListener( “system”, systemEvents )


– Scene listeners

scene:addEventListener(“createScene”, scene)

scene:addEventListener(“enterScene”, scene)

scene:addEventListener(“exitScene”, scene)

scene:addEventListener(“destroyScene”, scene)

return scene[/lua]

I’ve also tried commenting out the licensing stuff to no avail… I’m not sure what else I can try.

Hi @TwinTails,

This is most likely an issue in how you’ve set up Storyboard, its scope, and how you’re calling things in the Storyboard module(s). I recommend that you start with this video tutorial on Storyboard’s core functionality:

http://www.coronalabs.com/blog/2013/08/20/tutorial-reloading-storyboard-scenes/

Best regards,

Brent

Hello Brent,

I watched the video and moved my code (licensing+gpgs) inside my menu.lua “enterScene” function and then I got the login popup(success!) but it gave me the Sign-in error again like the sample.

Anyway, I did some searching and found the idea to re-link my package in the Dev Console and it’s working again! Thanks for the help :slight_smile:

-TT