I’ve been using this guide : https://coronalabs.com/blog/2013/06/25/tutorial-introducing-google-play-game-services/
A few things have changed since, but it’s seems to be up to date.
The GPGS has been set accordingly to the guide. Once my achievement have been added, I published them, after linking them to this app.
I’ve made a new app, with 3 buttons : a first one that connects to GPGS, a second one that unlocks an achievement and a third one, that simply shows the achievements list. Here is the code :
build.settings
settings = { plugins = { ["CoronaProvider.gameNetwork.google"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true }, }, }, orientation = { default = "landscapeRight", supported = { "landscapeLeft", "landscapeRight"}, }, android = { googlePlayGamesAppId = "XXXXXXXXXXXXX", versionCode = "1", versionName = "0.5", usesPermissions = { "android.permission.INTERNET", "android.permission.VIBRATE" }, }, }
main.lua
-------------------------------------------------------------------------------------------- -- Variables -------------------------------------------------------------------------------------------- local \_W = display.contentWidth \* 0.5; local \_H = display.contentHeight \* 0.5; local gameNetwork = require("gameNetwork") local initCallback local requestCallback -------------------------------------------------------------------------------------------- -- Initialization Callback -------------------------------------------------------------------------------------------- function initCallback(event) -- Android if not event.isError then --native.showAlert("Success!", "", { "OK" }) print("gameNetwork : connected") else --native.showAlert("Failed!", event.errorMessage, { "OK" }) print("Error Code:", event.errorCode) end end -------------------------------------------------------------------------------------------- -- Request Callback -------------------------------------------------------------------------------------------- function requestCallback(event) if (event.type == "unlockAchievement") then -- High score has been set print("event.type == unlockAchievement") end end -------------------------------------------------------------------------------------------- -- BUTTONS -------------------------------------------------------------------------------------------- local buttonListener local button01 local button02 local button03 button01 = display.newImage("button01.png") button01.x = \_W button01.y = \_H - 100 button01.action = "connect" button02 = display.newImage("button02.png") button02.x = \_W button02.y = \_H button02.action = "unlock" button03 = display.newImage("button03.png") button03.x = \_W button03.y = \_H + 100 button03.action = "show" function buttonListener(event) if event.phase == "ended" or event.phase == "cancelled" then -- Connecting to gameNetwork if event.target.action == "connect" then gameNetwork.init("google", initCallback) -- Unlocking achievement XXXXXXXXXXXXXXXXXX elseif event.target.action == "unlock" then gameNetwork.request("unlockAchievement", { achievement = { identifier = "XXXXXXXXXXXXXXXXXX" }, listener = requestCallback } ) -- Showing achievements elseif event.target.action == "show" then gameNetwork.show("achievements") end end end -- Adding touch events button01:addEventListener("touch", buttonListener) button02:addEventListener("touch", buttonListener) button03:addEventListener("touch", buttonListener)
And that’s it. I still have the same issue : button01 seems to successfully initializes gameNetwork(), while button02 and button03 do absolutely nothing. I don’t even have any output message.
At this point, my guess is that I’ve probably made a mistake while configuring GPGS, but honestly, I can’t be sure : I’m really not used to work with GPGS and I don’t know what to look or where to look.
I’ve tried installing the app on my tabled with an App Installer (“ES Explorateur”), and with Google Play (by setting the app as an alpha test). And I’ve tried to build my app with a debug keystore and also with a release keystore… Nothing changed.
And, just in case, I’m using Corona v2015.2772.