Google Play Game Services - init crashes app

When I try to init Google Play Game Services, I get an error message

“The Google Play services resources were not found. Check your project configuration to ensure that the resources are included”

(The login request does not execute, app crashes before).

I saw some threads about the same message for Corona Enterprise - but I’m on Pro.

Full log cat:

E/GooglePlayServicesUtil( 2706): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. I/Corona ( 2706): initGPGSCallback { I/Corona ( 2706): data = true, I/Corona ( 2706): name = "init", I/Corona ( 2706): type = "init" I/Corona ( 2706): } D/BaseGameActivity( 2706): onCreate: creating GamesClient I/dalvikvm( 2706): Could not find method android.view.View.getDisplay, referenced from method com.google.android.gms.internal.bv$b.b W/dalvikvm( 2706): VFY: unable to resolve virtual method 3997: Landroid/view/View;.getDisplay ()Landroid/view/Display; D/dalvikvm( 2706): VFY: replacing opcode 0x6e at 0x0009 D/dalvikvm( 2706): GC\_CONCURRENT freed 4350K, 34% free 8871K/13319K, paused 13ms+17ms, total 91ms E/GooglePlayServicesUtil( 2706): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. D/BaseGameActivity( 2706): isGooglePlayServicesAvailable returned 0 D/BaseGameActivity( 2706): beginUserInitiatedSignIn: starting new sign-in flow. D/BaseGameActivity( 2706): Connecting GamesClient. E/GooglePlayServicesUtil( 2706): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. W/GooglePlayServicesUtil( 724): Certificate has expired. W/GooglePlayServicesUtil( 724): Certificate has expired. E/ValidateServiceOp( 724): Using Google Play games services requires a metadata tag with the name "com.google.android.gms.games.APP\_ID" in the application tag of your manifest D/AndroidRuntime( 2706): Shutting down VM W/dalvikvm( 2706): threadid=1: thread exiting with uncaught exception (group=0x40e40300) D/FlurryAgent( 2706): Ending session E/AndroidRuntime( 2706): FATAL EXCEPTION: main E/AndroidRuntime( 2706): java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information. E/AndroidRuntime( 2706): at com.google.android.gms.internal.u$f.a(Unknown Source) E/AndroidRuntime( 2706): at com.google.android.gms.internal.u$f.a(Unknown Source) E/AndroidRuntime( 2706): at com.google.android.gms.internal.u$b.A(Unknown Source) E/AndroidRuntime( 2706): at com.google.android.gms.internal.u$a.handleMessage(Unknown Source) E/AndroidRuntime( 2706): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 2706): at android.os.Looper.loop(Looper.java:137) E/AndroidRuntime( 2706): at android.app.ActivityThread.main(ActivityThread.java:4745) E/AndroidRuntime( 2706): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 2706): at java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime( 2706): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) E/AndroidRuntime( 2706): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) E/AndroidRuntime( 2706): at dalvik.system.NativeStart.main(Native Method) W/ActivityManager( 249): Force finishing activity com.netzfrequenz.android.mygame/com.ansca.corona.CoronaActivity D/dalvikvm( 249): GC\_FOR\_ALLOC freed 655K, 16% free 15849K/18759K, paused 208ms, total 214ms W/ActivityManager( 249): Activity pause timeout for ActivityRecord{41cf1168 com.netzfrequenz.android.mygame/com.ansca.corona.CoronaActivity} D/dalvikvm( 2706): GC\_CONCURRENT freed 426K, 34% free 8885K/13319K, paused 14ms+2ms, total 69ms W/ActivityManager( 249): Activity destroy timeout for ActivityRecord{41cf1168 com.netzfrequenz.android.mygame/com.ansca.corona.CoronaActivity} D/dalvikvm( 249): GC\_CONCURRENT freed 1710K, 15% free 15991K/18759K, paused 14ms+13ms, total 154ms D/GCM ( 569): Ignoring attempt to send heartbeat on dead connection. W/Smack/Packet( 569): notify conn break (IOEx), close connection

Here’s my code:

main.lua:

local gameNetwork = require "gameNetwork" ... local function initGPGSCallback( event )    print ("initGPGSCallback " .. inspect(event))    gameNetwork.request( "login", { userInitiated=true, listener=gpgsLoginCallback } ) end gameNetwork.init( "google", initGPGSCallback )

build.settings:

settings = { orientation = { default = "portrait", supported = { "portrait", "portraitUpsideDown" }, }, android = { { versionCode = "2", googlePlayGamesAppId = "XXX676032XXX", -- Your Google Play Games App Id }, androidPermissions = { "android.permission.ACCESS\_FINE\_LOCATION", "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.ACCESS\_WIFI\_STATE", "android.permission.ACCESS\_NETWORK\_STATE" }, }, plugins = { ... ["CoronaProvider.gameNetwork.google"] = { publisherId = "com.coronalabs", }, } }

Any advice?

Thanks,

Thomas

So, my build.settings were wrong:

 android = { versionCode = "2", googlePlayGamesAppId = "XXXX6032XXX", -- Your Google Play Games App Id usesPermissions = { "android.permission.ACCESS\_FINE\_LOCATION", "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.ACCESS\_WIFI\_STATE", "android.permission.ACCESS\_NETWORK\_STATE" }, },

The crash is gone - I now get the “Connecting to Google Play Services” popup, which disappears after a few seconds.

But now the login fails (the callback is called with event.isError = true).

I/Corona ( 4410): initGPGSCallback { I/Corona ( 4410): data = true, I/Corona ( 4410): name = "init", I/Corona ( 4410): type = "init" I/Corona ( 4410): } I/Corona ( 4410): requesting login D/BaseGameActivity( 4410): onCreate: creating GamesClient I/dalvikvm( 4410): Could not find method android.view.View.getDisplay, referenced from method com.google.android.gms.internal.bv$b.b W/dalvikvm( 4410): VFY: unable to resolve virtual method 3997: Landroid/view/View;.getDisplay ()Landroid/view/Display; D/dalvikvm( 4410): VFY: replacing opcode 0x6e at 0x0009 E/GooglePlayServicesUtil( 4410): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. D/BaseGameActivity( 4410): isGooglePlayServicesAvailable returned 0 D/BaseGameActivity( 4410): beginUserInitiatedSignIn: starting new sign-in flow. D/BaseGameActivity( 4410): Connecting GamesClient. E/GooglePlayServicesUtil( 4410): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. D/dalvikvm( 724): WAIT\_FOR\_CONCURRENT\_GC blocked 0ms D/dalvikvm( 724): GC\_EXPLICIT freed 443K, 17% free 10000K/11975K, paused 12ms+12ms, total 146ms W/GooglePlayServicesUtil( 724): Certificate has expired. W/GooglePlayServicesUtil( 724): Certificate has expired. D/BaseGameActivity( 4410): onConnectionFailed: result 4 D/BaseGameActivity( 4410): onConnectionFailed: since user initiated sign-in, trying to resolve problem. D/BaseGameActivity( 4410): resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN\_IN\_REQUIRED, resolution=PendingIntent{419f8b78: android.os.BinderProxy@419fa4d8}} D/BaseGameActivity( 4410): result has resolution. Starting it. I/ActivityManager( 249): START {flg=0x4000000 cmp=com.google.android.gms/.games.ui.signin.SignInActivity (has extras) u=0} from pid -1 D/dalvikvm( 249): GC\_FOR\_ALLOC freed 1503K, 15% free 16244K/19015K, paused 192ms, total 200ms I/ActivityManager( 249): Start proc com.google.android.gms.ui for activity com.google.android.gms/.games.ui.signin.SignInActivity: pid=4503 uid=10018 gids={3003, 1015, 1028, 1007, 3002, 3001, 1006, 2001, 3006} D/FlurryAgent( 4410): Ending session D/dalvikvm( 4503): GC\_CONCURRENT freed 171K, 4% free 8324K/8583K, paused 18ms+15ms, total 64ms I/MultiDex( 4503): load(/data/app/com.google.android.gms-1.apk, forceReload=false) I/MultiDex( 4503): Need extracted file /data/data/com.google.android.gms/files/secondary-dexes/com.google.android.gms-1.apk.classes2.zip I/MultiDex( 4503): No extraction needed for /data/data/com.google.android.gms/files/secondary-dexes/com.google.android.gms-1.apk.classes2.zip of size 1547068 D/dalvikvm( 4503): GC\_CONCURRENT freed 141K, 3% free 8683K/8903K, paused 14ms+25ms, total 70ms D/GCM ( 569): GcmService start Intent { act=com.google.android.gms.INITIALIZE flg=0x10 pkg=com.google.android.gms cmp=com.google.android.gms/.gcm.GcmService } com.google.android.gms.INITIALIZE W/AudioWatchdog( 89): Insufficient CPU for load: expected=50.0 actual=103.7 ms; underruns=1 logs=1 E/dalvikvm( 4503): Could not find class 'android.app.AppOpsManager', referenced from method box.a W/dalvikvm( 4503): VFY: unable to resolve check-cast 341 (Landroid/app/AppOpsManager;) in Lbox; D/dalvikvm( 4503): VFY: replacing opcode 0x1f at 0x000e D/libEGL ( 4503): loaded /vendor/lib/egl/libEGL\_POWERVR\_SGX540\_120.so D/libEGL ( 4503): loaded /vendor/lib/egl/libGLESv1\_CM\_POWERVR\_SGX540\_120.so D/libEGL ( 4503): loaded /vendor/lib/egl/libGLESv2\_POWERVR\_SGX540\_120.so I/ActivityManager( 249): Process com.google.android.gms.drive (pid 4262) has died. D/OpenGLRenderer( 4503): Enabling debug mode 0 D/dalvikvm( 4503): GC\_FOR\_ALLOC freed 158K, 4% free 8720K/9031K, paused 36ms, total 37ms I/dalvikvm-heap( 4503): Grow heap (frag case) to 8.939MB for 362752-byte allocation D/dalvikvm( 4503): GC\_FOR\_ALLOC freed 301K, 7% free 8773K/9415K, paused 23ms, total 23ms I/ActivityManager( 249): Process android.process.media (pid 4003) has died. I/ActivityManager( 249): Displayed com.google.android.gms/.games.ui.signin.SignInActivity: +1s963ms I/ActivityManager( 249): Process com.google.android.inputmethod.latin.dictionarypack (pid 4173) has died. I/ActivityManager( 249): Process android.process.acore (pid 4122) has died. D/AudioHardware( 89): AudioHardware pcm playback is going to standby. D/AudioHardware( 89): closePcmOut\_l() mPcmOpenCnt: 1 D/dalvikvm( 249): WAIT\_FOR\_CONCURRENT\_GC blocked 0ms D/dalvikvm( 249): GC\_EXPLICIT freed 705K, 16% free 16156K/19015K, paused 17ms+12ms, total 195ms W/GLSUser ( 569): GoogleAccountDataService.getToken() E/dalvikvm( 4503): Could not find class 'android.os.UserManager', referenced from method bov.b W/dalvikvm( 4503): VFY: unable to resolve check-cast 558 (Landroid/os/UserManager;) in Lbov; D/dalvikvm( 4503): VFY: replacing opcode 0x1f at 0x000c I/dalvikvm( 4503): Could not find method android.accounts.AccountManager.getAccountsByTypeForPackage, referenced from method bov.c W/dalvikvm( 4503): VFY: unable to resolve virtual method 1428: Landroid/accounts/AccountManager;.getAccountsByTypeForPackage (Ljava/lang/String;Ljava/lang/String;)[Landroid/accounts/Account; D/dalvikvm( 4503): VFY: replacing opcode 0x6e at 0x000c E/dalvikvm( 4503): Could not find class 'android.os.UserManager', referenced from method bov.c W/dalvikvm( 4503): VFY: unable to resolve check-cast 558 (Landroid/os/UserManager;) in Lbov; D/dalvikvm( 4503): VFY: replacing opcode 0x1f at 0x000f E/dalvikvm( 4503): Could not find class 'android.os.UserManager', referenced from method bov.d W/dalvikvm( 4503): VFY: unable to resolve check-cast 558 (Landroid/os/UserManager;) in Lbov; D/dalvikvm( 4503): VFY: replacing opcode 0x1f at 0x000d W/GLSUser ( 569): GoogleAccountDataService.getToken() W/GLSUser ( 569): GoogleAccountDataService.getToken() W/GLSUser ( 569): GoogleAccountDataService.getToken() D/dalvikvm( 569): GC\_CONCURRENT freed 592K, 9% free 9992K/10887K, paused 18ms+6ms, total 319ms I/Corona ( 4410): [RevMob] Install received. E/GameAgent( 724): Unable to retrieve 1P application XXX76032XXX from network E/GameAgent( 724): Game ID (XXX676032XXX) was not found on server E/CheckGameplayAcl( 4503): Unable to load metadata for game W/SignInActivity( 4503): onSignInFailed()... W/SignInActivity( 4503): ==\> Returning non-OK result: 10004 D/BaseGameActivity( 4410): onActivityResult, req 1 response 10004 D/BaseGameActivity( 4410): responseCode != RESULT\_OK, so not reconnecting. D/BaseGameActivity( 4410): giveUp: giving up on connection. Status code: 4 I/Corona ( 4410): gpgsLoginCallback { I/Corona ( 4410): isError = true, I/Corona ( 4410): name = "login", I/Corona ( 4410): type = "login" I/Corona ( 4410): }

It says my Game ID is wrong - is this the “Application ID” from the android developer console (Linked apps -> Authorization - Application ID)? Or is the problem related to the state of my Android app (not published)?

OK, so I should have RTFM.

http://coronalabs.com/blog/2013/06/25/tutorial-introducing-google-play-game-services/

NOTE:  this step will take you through the process to create  OAuth2  login credentials for the linked app. It’s very important that you follow these steps carefully, including the steps to get the SHA1 Keystore signature. If you don’t do this, you won’t be able to connect to the service (and you cannot edit it later to fix it).

and https://developers.google.com/games/services/console/enabling#a_create_a_linked_application

Open a terminal and run the the Keytool utility to get the SHA1 fingerprint of the certificate. You should get both the release and debug certificate fingerprints.

Bottom line: Don’t just click “OK” and accept the auto-generated SHA1 fingerprint.
 

So, my build.settings were wrong:

 android = { versionCode = "2", googlePlayGamesAppId = "XXXX6032XXX", -- Your Google Play Games App Id usesPermissions = { "android.permission.ACCESS\_FINE\_LOCATION", "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.ACCESS\_WIFI\_STATE", "android.permission.ACCESS\_NETWORK\_STATE" }, },

The crash is gone - I now get the “Connecting to Google Play Services” popup, which disappears after a few seconds.

But now the login fails (the callback is called with event.isError = true).

I/Corona ( 4410): initGPGSCallback { I/Corona ( 4410): data = true, I/Corona ( 4410): name = "init", I/Corona ( 4410): type = "init" I/Corona ( 4410): } I/Corona ( 4410): requesting login D/BaseGameActivity( 4410): onCreate: creating GamesClient I/dalvikvm( 4410): Could not find method android.view.View.getDisplay, referenced from method com.google.android.gms.internal.bv$b.b W/dalvikvm( 4410): VFY: unable to resolve virtual method 3997: Landroid/view/View;.getDisplay ()Landroid/view/Display; D/dalvikvm( 4410): VFY: replacing opcode 0x6e at 0x0009 E/GooglePlayServicesUtil( 4410): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. D/BaseGameActivity( 4410): isGooglePlayServicesAvailable returned 0 D/BaseGameActivity( 4410): beginUserInitiatedSignIn: starting new sign-in flow. D/BaseGameActivity( 4410): Connecting GamesClient. E/GooglePlayServicesUtil( 4410): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. D/dalvikvm( 724): WAIT\_FOR\_CONCURRENT\_GC blocked 0ms D/dalvikvm( 724): GC\_EXPLICIT freed 443K, 17% free 10000K/11975K, paused 12ms+12ms, total 146ms W/GooglePlayServicesUtil( 724): Certificate has expired. W/GooglePlayServicesUtil( 724): Certificate has expired. D/BaseGameActivity( 4410): onConnectionFailed: result 4 D/BaseGameActivity( 4410): onConnectionFailed: since user initiated sign-in, trying to resolve problem. D/BaseGameActivity( 4410): resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN\_IN\_REQUIRED, resolution=PendingIntent{419f8b78: android.os.BinderProxy@419fa4d8}} D/BaseGameActivity( 4410): result has resolution. Starting it. I/ActivityManager( 249): START {flg=0x4000000 cmp=com.google.android.gms/.games.ui.signin.SignInActivity (has extras) u=0} from pid -1 D/dalvikvm( 249): GC\_FOR\_ALLOC freed 1503K, 15% free 16244K/19015K, paused 192ms, total 200ms I/ActivityManager( 249): Start proc com.google.android.gms.ui for activity com.google.android.gms/.games.ui.signin.SignInActivity: pid=4503 uid=10018 gids={3003, 1015, 1028, 1007, 3002, 3001, 1006, 2001, 3006} D/FlurryAgent( 4410): Ending session D/dalvikvm( 4503): GC\_CONCURRENT freed 171K, 4% free 8324K/8583K, paused 18ms+15ms, total 64ms I/MultiDex( 4503): load(/data/app/com.google.android.gms-1.apk, forceReload=false) I/MultiDex( 4503): Need extracted file /data/data/com.google.android.gms/files/secondary-dexes/com.google.android.gms-1.apk.classes2.zip I/MultiDex( 4503): No extraction needed for /data/data/com.google.android.gms/files/secondary-dexes/com.google.android.gms-1.apk.classes2.zip of size 1547068 D/dalvikvm( 4503): GC\_CONCURRENT freed 141K, 3% free 8683K/8903K, paused 14ms+25ms, total 70ms D/GCM ( 569): GcmService start Intent { act=com.google.android.gms.INITIALIZE flg=0x10 pkg=com.google.android.gms cmp=com.google.android.gms/.gcm.GcmService } com.google.android.gms.INITIALIZE W/AudioWatchdog( 89): Insufficient CPU for load: expected=50.0 actual=103.7 ms; underruns=1 logs=1 E/dalvikvm( 4503): Could not find class 'android.app.AppOpsManager', referenced from method box.a W/dalvikvm( 4503): VFY: unable to resolve check-cast 341 (Landroid/app/AppOpsManager;) in Lbox; D/dalvikvm( 4503): VFY: replacing opcode 0x1f at 0x000e D/libEGL ( 4503): loaded /vendor/lib/egl/libEGL\_POWERVR\_SGX540\_120.so D/libEGL ( 4503): loaded /vendor/lib/egl/libGLESv1\_CM\_POWERVR\_SGX540\_120.so D/libEGL ( 4503): loaded /vendor/lib/egl/libGLESv2\_POWERVR\_SGX540\_120.so I/ActivityManager( 249): Process com.google.android.gms.drive (pid 4262) has died. D/OpenGLRenderer( 4503): Enabling debug mode 0 D/dalvikvm( 4503): GC\_FOR\_ALLOC freed 158K, 4% free 8720K/9031K, paused 36ms, total 37ms I/dalvikvm-heap( 4503): Grow heap (frag case) to 8.939MB for 362752-byte allocation D/dalvikvm( 4503): GC\_FOR\_ALLOC freed 301K, 7% free 8773K/9415K, paused 23ms, total 23ms I/ActivityManager( 249): Process android.process.media (pid 4003) has died. I/ActivityManager( 249): Displayed com.google.android.gms/.games.ui.signin.SignInActivity: +1s963ms I/ActivityManager( 249): Process com.google.android.inputmethod.latin.dictionarypack (pid 4173) has died. I/ActivityManager( 249): Process android.process.acore (pid 4122) has died. D/AudioHardware( 89): AudioHardware pcm playback is going to standby. D/AudioHardware( 89): closePcmOut\_l() mPcmOpenCnt: 1 D/dalvikvm( 249): WAIT\_FOR\_CONCURRENT\_GC blocked 0ms D/dalvikvm( 249): GC\_EXPLICIT freed 705K, 16% free 16156K/19015K, paused 17ms+12ms, total 195ms W/GLSUser ( 569): GoogleAccountDataService.getToken() E/dalvikvm( 4503): Could not find class 'android.os.UserManager', referenced from method bov.b W/dalvikvm( 4503): VFY: unable to resolve check-cast 558 (Landroid/os/UserManager;) in Lbov; D/dalvikvm( 4503): VFY: replacing opcode 0x1f at 0x000c I/dalvikvm( 4503): Could not find method android.accounts.AccountManager.getAccountsByTypeForPackage, referenced from method bov.c W/dalvikvm( 4503): VFY: unable to resolve virtual method 1428: Landroid/accounts/AccountManager;.getAccountsByTypeForPackage (Ljava/lang/String;Ljava/lang/String;)[Landroid/accounts/Account; D/dalvikvm( 4503): VFY: replacing opcode 0x6e at 0x000c E/dalvikvm( 4503): Could not find class 'android.os.UserManager', referenced from method bov.c W/dalvikvm( 4503): VFY: unable to resolve check-cast 558 (Landroid/os/UserManager;) in Lbov; D/dalvikvm( 4503): VFY: replacing opcode 0x1f at 0x000f E/dalvikvm( 4503): Could not find class 'android.os.UserManager', referenced from method bov.d W/dalvikvm( 4503): VFY: unable to resolve check-cast 558 (Landroid/os/UserManager;) in Lbov; D/dalvikvm( 4503): VFY: replacing opcode 0x1f at 0x000d W/GLSUser ( 569): GoogleAccountDataService.getToken() W/GLSUser ( 569): GoogleAccountDataService.getToken() W/GLSUser ( 569): GoogleAccountDataService.getToken() D/dalvikvm( 569): GC\_CONCURRENT freed 592K, 9% free 9992K/10887K, paused 18ms+6ms, total 319ms I/Corona ( 4410): [RevMob] Install received. E/GameAgent( 724): Unable to retrieve 1P application XXX76032XXX from network E/GameAgent( 724): Game ID (XXX676032XXX) was not found on server E/CheckGameplayAcl( 4503): Unable to load metadata for game W/SignInActivity( 4503): onSignInFailed()... W/SignInActivity( 4503): ==\> Returning non-OK result: 10004 D/BaseGameActivity( 4410): onActivityResult, req 1 response 10004 D/BaseGameActivity( 4410): responseCode != RESULT\_OK, so not reconnecting. D/BaseGameActivity( 4410): giveUp: giving up on connection. Status code: 4 I/Corona ( 4410): gpgsLoginCallback { I/Corona ( 4410): isError = true, I/Corona ( 4410): name = "login", I/Corona ( 4410): type = "login" I/Corona ( 4410): }

It says my Game ID is wrong - is this the “Application ID” from the android developer console (Linked apps -> Authorization - Application ID)? Or is the problem related to the state of my Android app (not published)?

OK, so I should have RTFM.

http://coronalabs.com/blog/2013/06/25/tutorial-introducing-google-play-game-services/

NOTE:  this step will take you through the process to create  OAuth2  login credentials for the linked app. It’s very important that you follow these steps carefully, including the steps to get the SHA1 Keystore signature. If you don’t do this, you won’t be able to connect to the service (and you cannot edit it later to fix it).

and https://developers.google.com/games/services/console/enabling#a_create_a_linked_application

Open a terminal and run the the Keytool utility to get the SHA1 fingerprint of the certificate. You should get both the release and debug certificate fingerprints.

Bottom line: Don’t just click “OK” and accept the auto-generated SHA1 fingerprint.