Google Play Game Services init not working

Hi,

I’m having some real problems getting google play game services to work in my app. The issue is that 

gameNetwork.init() seems to hang.

I’ve gone through the steps of adding a new application, adding a new game via the Game Services Icon, linking it and setting the keystore ID correctly.

I’ve now stripped the code down  to the bare essentials.

build.settings

settings = { android = { googlePlayGamesAppId = "1054372640256", -- Your Google Play Games App Id }, plugins = { -- key is the name passed to Lua's 'require()' ["CoronaProvider.gameNetwork.google"] = { -- required publisherId = "com.coronalabs", }, }, }

main.lua

local gameNetwork = require "gameNetwork" local init; local function initCallback( event ) if not event.isError then init = true native.showAlert( "Success!", "", { "OK" } ) else init = false native.showAlert( "Failed!", event.errorMessage, {"OK"}) print("Error Code: ", event.errorCode) end end native.showAlert( "Calling gameNetwork.init", "", { "OK" } ) gameNetwork.init( "google", initCallback ) native.showAlert( "Calling login", "", { "OK" } ) local function requestCallback(isError) if (isError) then native.showAlert( "login error", "", { "OK" } ) else native.showAlert( "login sucessful", "", { "OK" } ) end end gameNetwork.request( "login", { userInitiated = true, listener = requestCallback }) native.showAlert( "Calling leaderboards", "", { "OK" } ) gameNetwork.show( "leaderboards" ) --gameNetwork.show( "achievements" )

When I test  on the Samsung Galaxy S3 and HTC One, the only native popup  I get is:

“Calling gameNetwork.init” 

So it looks as if the app is hanging on gameNetwork.init 

I’ve tried this on build  2013.1137 and 2013.1191 and both have the same issue.

I am using a game services test account (not published yet) and the apk has not been uploaded to google play (I assume it does not need to be yet).

I really don’t know where to start debugging this.

Any help would be really appreciated!

Cheers,

Anthony

What happens when you dismiss the popup that says “Calling gameNetwork.init()”?  It’s possible that the code appears to “hang” simply because the popup is open and waiting for a response.  Also, calling multiple popups in a row can sometimes cause strange behavior (I think).

Instead of using popups to see where you code is, you should use print statements and monitor them with adb logcat.  It’s must easier and more efficient.  See this blog post for information about it: http://www.coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

  • Andrew

Great tip, thanks Andrew! That has made life so much easier. OK, so new code is:

local gameNetwork = require "gameNetwork" local init; local function initCallback( event ) if not event.isError then init = true print("initCallback success"); else init = false print("initCallback failed", event.errorMessage); end end print( "Calling gameNetwork.init") gameNetwork.init( "google", initCallback ) local function requestCallback(isError) if (isError) then print("login failed") else print("login success") end end print("Calling login") gameNetwork.request( "login", { userInitiated = true, listener = requestCallback }) print("calling leaderboards") gameNetwork.show( "leaderboards" ) --print("calling achievements") --gameNetwork.show( "achievements" )

build.settings as before.

log cat gives me

--------- beginning of /dev/log/system --------- beginning of /dev/log/main V/Corona (32106): \> Class.forName: network.LuaLoader V/Corona (32106): \< Class.forName: network.LuaLoader V/Corona (32106): Loading via reflection: network.LuaLoader V/Corona (32106): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (32106): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (32106): Loading via reflection: CoronaProvider.licensing.google.LuaLoader I/Corona (32106): Calling gameNetwork.init V/Corona (32106): \> Class.forName: CoronaProvider.gameNetwork.google.LuaLoader V/Corona (32106): \< Class.forName: CoronaProvider.gameNetwork.google.LuaLoader V/Corona (32106): Loading via reflection: CoronaProvider.gameNetwork.google.LuaLoader I/Corona (32106): Calling login I/Corona (32106): calling leaderboards I/Corona (32106): initCallback failed Service Missing

So the google play game service is missing? Odd. Does this mean the plugin has not been loaded correctly?

For this test I’m using dailybuild 2013.1191

and I’ve noticed that it no longer asks whether to download the plugin.

Any help greatly appreciated!

Thanks,

Anthony

I cannae believe it … I neglected to install the Google Play Games on the phone …  hide my head in shame for “overfocussing”.

So at least now the test app is functioning on Galaxy S3…!

What happens when you dismiss the popup that says “Calling gameNetwork.init()”?  It’s possible that the code appears to “hang” simply because the popup is open and waiting for a response.  Also, calling multiple popups in a row can sometimes cause strange behavior (I think).

Instead of using popups to see where you code is, you should use print statements and monitor them with adb logcat.  It’s must easier and more efficient.  See this blog post for information about it: http://www.coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

  • Andrew

Great tip, thanks Andrew! That has made life so much easier. OK, so new code is:

local gameNetwork = require "gameNetwork" local init; local function initCallback( event ) if not event.isError then init = true print("initCallback success"); else init = false print("initCallback failed", event.errorMessage); end end print( "Calling gameNetwork.init") gameNetwork.init( "google", initCallback ) local function requestCallback(isError) if (isError) then print("login failed") else print("login success") end end print("Calling login") gameNetwork.request( "login", { userInitiated = true, listener = requestCallback }) print("calling leaderboards") gameNetwork.show( "leaderboards" ) --print("calling achievements") --gameNetwork.show( "achievements" )

build.settings as before.

log cat gives me

--------- beginning of /dev/log/system --------- beginning of /dev/log/main V/Corona (32106): \> Class.forName: network.LuaLoader V/Corona (32106): \< Class.forName: network.LuaLoader V/Corona (32106): Loading via reflection: network.LuaLoader V/Corona (32106): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (32106): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (32106): Loading via reflection: CoronaProvider.licensing.google.LuaLoader I/Corona (32106): Calling gameNetwork.init V/Corona (32106): \> Class.forName: CoronaProvider.gameNetwork.google.LuaLoader V/Corona (32106): \< Class.forName: CoronaProvider.gameNetwork.google.LuaLoader V/Corona (32106): Loading via reflection: CoronaProvider.gameNetwork.google.LuaLoader I/Corona (32106): Calling login I/Corona (32106): calling leaderboards I/Corona (32106): initCallback failed Service Missing

So the google play game service is missing? Odd. Does this mean the plugin has not been loaded correctly?

For this test I’m using dailybuild 2013.1191

and I’ve noticed that it no longer asks whether to download the plugin.

Any help greatly appreciated!

Thanks,

Anthony

I cannae believe it … I neglected to install the Google Play Games on the phone …  hide my head in shame for “overfocussing”.

So at least now the test app is functioning on Galaxy S3…!

think I’ve hit the same issue :slight_smile:    

Actually (dumb question) but I’m having trouble trying to confirm:

Q1 - What is the minimum Google apps I need loaded on my old android device to make game services work, and

Q2 -  How do I search the Google Market place on my android phone to find a few games that utilise game services?  

update - just bought a new Android device for testing (vs the old device I had) and just seems to work - perhaps earlier versions of Android required you to manually download what was required for game services?

think I’ve hit the same issue :slight_smile:    

Actually (dumb question) but I’m having trouble trying to confirm:

Q1 - What is the minimum Google apps I need loaded on my old android device to make game services work, and

Q2 -  How do I search the Google Market place on my android phone to find a few games that utilise game services?  

update - just bought a new Android device for testing (vs the old device I had) and just seems to work - perhaps earlier versions of Android required you to manually download what was required for game services?