Hi,
I’d discovered an oddity which causes a crash with google play games.
Here is the scenario, tested with Samsung Galaxy S
-
Wifi connection
-
Run test app (code below). This will log on to the game server. Press Submit Score to submit a new high score. Check the score is submitted by pressing “Display Leaderboard”
once logged in to Google Play Games, exit the app
-
Switch to mobile connection
-
Run the app again and press Submit Score
This time the app crashes. Log file via adb show below
The bug appears to be to do with the callback listener from gameNetwork.request()
If the listener line is removed the app does not crash.
Also, with the mobile connection, the high score is not submitted correctly so perhaps the issue is concerned with Corona’s error handling when there is a poor network connection.
Hope this helps someone! Just make sure you do not use a callback from the setHighScore to prevent the crash.
Anthony
local gameNetwork = require "gameNetwork" local widget = require "widget" local loggedInStatus -- needs to be global as there will be several instances accessing this -- 0 = not initialised -- 1 = initialised -- 2 = logged in -- 3 = log in error local isSimulator = "simulator" == system.getInfo("environment") loggedInStatus = 0; local function submitScoreListener(event) print("submitting score") local function requestCallback(event) print("submitted score") end gameNetwork.request("setHighScore", { localPlayerScore = { category = "CgkInqXP58wYEAIQAQ", -- Id of the leaderboard to submit the score into value = 1234567 -- The score to submit }, listener=requestCallback -- remove this line to prevent crash }) end local scoreSubmitButton = widget.newButton { top = 0.2\*display.contentHeight, left = 0, width = 0.5\*display.contentWidth, height = 0.2\*display.contentHeight, label = "Submit Score", fontSize = buttonTextSize, onRelease = submitScoreListener, } local function gotoLeaderBoard() if (loggedInStatus == 2) then print("displaying board", theCategory); gameNetwork.show("leaderboards"); end end local displayLeaderBoard = widget.newButton { top = 0.5\*display.contentHeight, left = 0, width = 0.5\*display.contentWidth, height = 0.2\*display.contentHeight, label = "Display Leaderboard", fontSize = buttonTextSize, onRelease = gotoLeaderBoard, } local function initCallback( event ) if not event.isError then loggedInStatus = 1 print("initCallback: Google play initialised, calling login") local function logInCallback(event) if (event.isError) then loggedInStatus = 3 print( "google play login failed") else loggedInStatus = 2 print( "google play logged in ok") end end gameNetwork.request( "login", { userInitiated=true, listener=logInCallback }) else loggedInStatus = 0 print("initCallback error: Google play initialised") end end if (not isSimulator) then print("initialising google play") gameNetwork.init("google", initCallback) end
I/Corona (13532): initialising google play V/Corona (13532): \> Class.forName: CoronaProvider.gameNetwork.google.LuaLoader V/Corona (13532): \< Class.forName: CoronaProvider.gameNetwork.google.LuaLoader V/Corona (13532): Loading via reflection: CoronaProvider.gameNetwork.google.LuaLoader I/Corona (13532): initCallback: Google play initialised, calling login I/Corona (13532): google play logged in ok I/Corona (13532): submitting score W/dalvikvm(13532): threadid=9: thread exiting with uncaught exception (group=0x4001d7d0) E/AndroidRuntime(13532): FATAL EXCEPTION: GLThread 16 E/AndroidRuntime(13532): java.lang.NullPointerException E/AndroidRuntime(13532): at CoronaProvider.gameNetwork.google.SetHighScoreListener$1.executeUsing(SetHighScoreListener.java:55) E/AndroidRuntime(13532): at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:153) E/AndroidRuntime(13532): at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:229) E/AndroidRuntime(13532): at com.ansca.corona.Controller.updateRuntimeState(Controller.java:223) E/AndroidRuntime(13532): at com.ansca.corona.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:399) E/AndroidRuntime(13532): at com.ansca.corona.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622) E/AndroidRuntime(13532): at com.ansca.corona.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377) E/SensorManager(13532): unregisterListener: android.view.OrientationEventListener$SensorEventListenerImpl@4812b4c8 E/libEGL (13532): call to OpenGL ES API with no current context (logged once per thread)