Thank you for your response Rob.
Here’s the code leaderboard handler I created:
local isAndroid = false local isiOS = false local targetAppStore = system.getInfo( "targetAppStore" ) local leaderboardIDs = { "leaderboardid1", -- those are placeholder IDs for the purpose of this post. "leaderboardid2" -- In my code I have the real values from Play Store Console. } if ( "apple" == targetAppStore ) then -- iOS isiOS = true elseif ( "google" == targetAppStore ) then -- Android isAndroid = true local licensing = require( "licensing" ) local function licensingListener( event ) if not ( event.isVerified ) then native.showAlert( "Event!", "You're a pirate!", { "OK" } ) else native.showAlert( "Event!", "You're not a pirate!", { "OK" } ) end end local licensingInit = licensing.init( "google" ) if ( licensingInit == true ) then licensing.verify( licensingListener ) else end end local gameNetwork = nil local gpgs = nil if isiOS then gameNetwork = require( "gameNetwork" ) end if isAndroid then gpgs = require( "plugin.gpgs.v2" ) gpgs.enableDebug() end local m = {} local function initCallback( event ) if isAndroid then if not event.isError then if ( event.name == "init" ) then native.showAlert( "Submit Event!", "Init call back", { "OK" } ) gpgs.login( { userInitiated=true, listener=initCallback } ) elseif ( event.name == "login" ) then native.showAlert( "Submit Event!", "Login call back", { "OK" } ) end else native.showAlert( "Submit Event!", "Error in initcallback: "..event.name, { "OK" } ) end else native.showAlert( "Submit Event!", "Now android: "..event.name, { "OK" } ) end end function m.init() if m.didInit then return end m.didInit = true if isiOS then gameNetwork.init( "gamecenter", initCallback ) elseif isAndroid then gpgs.init(initCallback) end end function m.setTopScore( score, leaderboardIndex ) if isiOS then local categories = { "com.frikado.leaderboard.park", "com.frikado.leaderboard.room" } gameNetwork.request( "setHighScore", { localPlayerScore = { category=categories[leaderboardIndex], value=score }}) elseif isAndroid then local function submitCallback(event) native.showAlert( "Submit Event!", "Set Top Score", { "OK" } ) end gpgs.leaderboards.submit({ leaderboardId = leaderboardIDs[leaderboardIndex], score = score, listener = submitCallback }) end end function m.showLeaderboards() if isiOS then gameNetwork.show( "leaderboards" ) elseif isAndroid then local function showCallback(event) native.showAlert( "Show Event!", "Show Leaderboard", { "OK" } ) end gpgs.leaderboards.show({listener = showCallback}) end end return m
I tried with Corona versions 3326 and 3441. It’s happening with both.
I’m testing on a Galaxy S6 with Android 7.0; I also made sure to update Google Play Store Game Services form the play store before posting this. The device is not rooted.
I was initially signing with the app store key. After signing with the debug key I get the error saying:
attempt to call field ‘init’ (a nil value) // On the line where it says “gpgs.init(initCallback)” in the code above.
I went over the Google Play developer console requirements multiple times. Could anything related to that be causing the issue?
It’s worth mentioning that in the build.settings file I have
[“plugin.gpgs.v2”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
Thank you for your help!