App does not connect to Google Play Service

Hello everyone,

I am trying to have a leaderboard in my game using the google play game service.

I am following this tutorial: https://coronalabs.com/blog/2013/06/25/tutorial-introducing-google-play-game-services/

to implement the plugin.

However it seems that I cannot reach successful connection to the server.

I have added print statement to my code to see where it is failing;

here is my code below:

my build setting:

android =     {     googlePlayGamesAppId = "MyAppId" -- I ve added my appId here } plugins =     {           ["CoronaProvider.gameNetwork.google"] =         {             publisherId = "com.coronalabs"         } }

and I have a button on my main screen that executes the following code:

  local function onButton()     print('I want the LD here')   local gameNetwork = require( "gameNetwork" ) local playerName   local function loadLocalPlayerCallback( event )    playerName = event.data.alias    print("Step 4")    --saveSettings()  --save player data locally using your own "saveSettings()" function end   local function gameNetworkLoginCallback( event )    gameNetwork.request( "loadLocalPlayer", { listener=loadLocalPlayerCallback } )    print("Step 3")    return true end   local function gpgsInitCallback( event )    gameNetwork.request( "login", { userInitiated=true, listener=gameNetworkLoginCallback } )    print("Step 2") end   local function gameNetworkSetup()    if ( system.getInfo("platformName") == "Android" ) then       gameNetwork.init( "google", gpgsInitCallback )       print("Step 1")    else       gameNetwork.init( "gamecenter", gameNetworkLoginCallback )    end end ------HANDLE SYSTEM EVENTS------ gameNetworkSetup()  --login to the network here end

So when I run adb logcat Corona:v *:s and click on the button I reach;

Step 1, 2 and 3 but NOT step 4.

It is said in the tutorial:

“Once the proper service is initiated, we use gameNetwork.request() again to log in the player locally. Assuming this is successful, the loadLocalPlayerCallback() function is called.”

I do not think I reach the loadLocalPlayerCallback() function here, am I right?

Also could someone explain me why we need a saveSetting() function here?

Thank you for your help

JJ

 

Please try again but leave the “Corona:v *:s” off of the adb logcat. Just run it like “adb logcat”. When you include the extra bits, it only shows you messages printed by Corona. You need to see messages printed from Google Play Game Services. This will cause a lot of stuff to be output. You just have to be diligent in looking through all the messages. But they should be near your Corona prints.

Rob

Hello Rob,

Thank you very much for your help.

I have left out the "“Corona:v *:s” (actually quite handy to check other things)

I have output the Google play game services messages:

I get the followings:

E/GooglePlayServicesUtil(23020): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

and I also get:

E/GameAgent( 5284): Unable to retrieve application *insert 12 digits app id here* from network
E/GameAgent( 5284): Application *insert 12 digits app id here* is not associated with package com.myname.myapp. Check the application ID in your manifest.

I am not sure what is wrong here.

When I build the app, I use the same package name as mentioned above.

on the google play developper console, I have the app id under the name of the app and the package name is as the one above com.myname.myapp.

I must miss something somewhere that I do not get :wink:

Thanks in advance,

JJ

Can you post your complete build.settings please?

yes of course :slight_smile:

settings = {     plugins =     {           ["CoronaProvider.gameNetwork.google"] =         {             publisherId = "com.coronalabs"         },           ["plugin.google.play.services"] =         {             publisherId = "com.coronalabs",             supportedPlatforms = { iphone=true, android=true }         },     },          orientation =     {         default = "portrait",         supported = { "portrait", }     },          excludeFiles =     {         -- Include only the necessary icon files on each platform         iphone = { "Icon-\*dpi.png", },         android = { "Icon.png", "Icon-Small-\*.png", "Icon\*@2x.png", },     },     --     -- iOS Section     --     iphone =     {         plist =         {             UIStatusBarHidden = false,             UIPrerenderedIcon = true, -- set to false for "shine" overlay             --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend             CFBundleIconFiles =             {                 "Icon.png",                 "Icon@2x.png",                 "Icon-167.png",                 "Icon-60.png",                 "Icon-60@2x.png",                 "Icon-60@3x.png",                 "Icon-72.png",                 "Icon-72@2x.png",                 "Icon-76.png",                 "Icon-76@2x.png",                 "Icon-Small.png",                 "Icon-Small@2x.png",                 "Icon-Small@3x.png",                 "Icon-Small-40.png",                 "Icon-Small-40@2x.png",                 "Icon-Small-50.png",                 "Icon-Small-50@2x.png",             },             --[[            -- iOS app URL schemes:             CFBundleURLTypes =             {                 {                     CFBundleURLSchemes =                     {                         "fbXXXXXXXXX",  -- replace XXXXXXXXX with your Facebook appId                     }                 }             }             --]]         }     },          --     -- Android Section     --     android =     {     googlePlayGamesAppId = "15\*\*\*\*\*\*\*\*16",         usesPermissions =         {             "android.permission.INTERNET",       "android.permission.ACCESS\_NETWORK\_STATE"         },     }, }

Thanks for your help.

Ok so I have tried to fix the problem following these steps where people seemed to have a similar problem:

http://stackoverflow.com/questions/16580885/google-play-game-services-unable-to-sign-in

So I have unlinked my app in the google play developer console and my project in my google api console.

I have redone everything from scratch especially for the creation of a keystore using steps provided by:

https://forums.coronalabs.com/topic/49992-problem-in-opening-leaderboards-on-google-play-game-services/

But nothing fixed the problem and I still get the two errors when I try to log in :

E/GameAgent( 1446): Unable to retrieve application 53********74 from network

E/GameAgent( 1446): Application 53********74 is not associated with package com.jo*******r.c******t. Check the application ID in your manifest.

So using the apktool to look at the the AndroidManifest.xml I can check my application ID.

It is like this: <meta-data android:name=“com.google.android.gms.games.APP_ID” android:value="/ 53********74"/>

It seems that I have a space between the first slash and the first number.

However on the developpers goolgle website:

https://developers.google.com/games/services/android/troubleshooting

it is said that it should be like this:

<meta-data android:name=“com.google.android.gms.games.APP_ID”

    android:value="@string/app_id" />

Could it be the reason why I am failing signing in? because it is slightly different.

Or Do I do something wrong during the build? 

I should also mention that I tried with a different code given by coronalabs on githubs:

https://github.com/coronalabs/plugins-sample-gameNetwork-google

Thanks again for anyone who could help me or even guide me 

In your build settings your googlePlayGamesAppId starts with a 15 and ends with a 16. The console log is finding a 53 and a 74 at the start and end. Which one is accurate?

You can always hand type that line just in case some non-ASCII characters got in there (like smart quotes, etc. The / is definitely weird.

We should be putting the right value in there and you should not need to modify it.

Rob

yeah sorry, because in my previous post I had a different app id, as I mentioned in the new one I have redone everything from scratch to be sure there was no mistake in it.

So the new app id is now starting with 53 and 74

my build setting is now : googlePlayGamesAppId =“53********74” (btw I am not sure how dangerous it is to write the whole app id on a forum :wink: )

I have also updated to the latest corona sdk build just in case but it did not make any difference.

My question is how can I change the manifest.xml file and  rebuilt everything to an apk file.

Do you think the problem is coming from the way I create the app on google play developer console. Cause to me it seems right.

I am getting  a bit lost now and not sure what I should do to get it right.

Thanks a lot for you help again.

Ok, I knew it was obviously something stupid on my side. I am a bit embarrassed to admit that but my email addresses for the google account on the dev console and on my phone were different. So I had to add a beta tester with the correct email address. 

and badaboum it worked !!! Can now see leaderboards and everything.

Thanks a lot for your help.

Cheers,

JJ

Please try again but leave the “Corona:v *:s” off of the adb logcat. Just run it like “adb logcat”. When you include the extra bits, it only shows you messages printed by Corona. You need to see messages printed from Google Play Game Services. This will cause a lot of stuff to be output. You just have to be diligent in looking through all the messages. But they should be near your Corona prints.

Rob

Hello Rob,

Thank you very much for your help.

I have left out the "“Corona:v *:s” (actually quite handy to check other things)

I have output the Google play game services messages:

I get the followings:

E/GooglePlayServicesUtil(23020): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

and I also get:

E/GameAgent( 5284): Unable to retrieve application *insert 12 digits app id here* from network
E/GameAgent( 5284): Application *insert 12 digits app id here* is not associated with package com.myname.myapp. Check the application ID in your manifest.

I am not sure what is wrong here.

When I build the app, I use the same package name as mentioned above.

on the google play developper console, I have the app id under the name of the app and the package name is as the one above com.myname.myapp.

I must miss something somewhere that I do not get :wink:

Thanks in advance,

JJ

Can you post your complete build.settings please?

yes of course :slight_smile:

settings = { &nbsp;&nbsp;&nbsp; plugins = &nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ["CoronaProvider.gameNetwork.google"] = &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; publisherId = "com.coronalabs" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ["plugin.google.play.services"] = &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; publisherId = "com.coronalabs", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; supportedPlatforms = { iphone=true, android=true } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }, &nbsp;&nbsp;&nbsp; }, &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;orientation = &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;default = "portrait", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;supported = { "portrait", } &nbsp;&nbsp; &nbsp;}, &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;excludeFiles = &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Include only the necessary icon files on each platform &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;iphone = { "Icon-\*dpi.png", }, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;android = { "Icon.png", "Icon-Small-\*.png", "Icon\*@2x.png", }, &nbsp;&nbsp; &nbsp;}, &nbsp;&nbsp; &nbsp;-- &nbsp;&nbsp; &nbsp;-- iOS Section &nbsp;&nbsp; &nbsp;-- &nbsp;&nbsp; &nbsp;iphone = &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;plist = &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;UIStatusBarHidden = false, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;UIPrerenderedIcon = true, -- set to false for "shine" overlay &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;--UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;CFBundleIconFiles = &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon@2x.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-167.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-60.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-60@2x.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-60@3x.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-72.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-72@2x.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-76.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-76@2x.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-Small.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-Small@2x.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-Small@3x.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-Small-40.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-Small-40@2x.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-Small-50.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"Icon-Small-50@2x.png", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;--[[&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- iOS app URL schemes: &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;CFBundleURLTypes = &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;CFBundleURLSchemes = &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"fbXXXXXXXXX",&nbsp; -- replace XXXXXXXXX with your Facebook appId &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;--]] &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;}, &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;-- &nbsp;&nbsp; &nbsp;-- Android Section &nbsp;&nbsp; &nbsp;-- &nbsp;&nbsp; &nbsp;android = &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp;&nbsp; googlePlayGamesAppId = "15\*\*\*\*\*\*\*\*16", &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;usesPermissions = &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;"android.permission.INTERNET", &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "android.permission.ACCESS\_NETWORK\_STATE" &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}, &nbsp;&nbsp; &nbsp;}, }

Thanks for your help.

Ok so I have tried to fix the problem following these steps where people seemed to have a similar problem:

http://stackoverflow.com/questions/16580885/google-play-game-services-unable-to-sign-in

So I have unlinked my app in the google play developer console and my project in my google api console.

I have redone everything from scratch especially for the creation of a keystore using steps provided by:

https://forums.coronalabs.com/topic/49992-problem-in-opening-leaderboards-on-google-play-game-services/

But nothing fixed the problem and I still get the two errors when I try to log in :

E/GameAgent( 1446): Unable to retrieve application 53********74 from network

E/GameAgent( 1446): Application 53********74 is not associated with package com.jo*******r.c******t. Check the application ID in your manifest.

So using the apktool to look at the the AndroidManifest.xml I can check my application ID.

It is like this: <meta-data android:name=“com.google.android.gms.games.APP_ID” android:value="/ 53********74"/>

It seems that I have a space between the first slash and the first number.

However on the developpers goolgle website:

https://developers.google.com/games/services/android/troubleshooting

it is said that it should be like this:

<meta-data android:name=“com.google.android.gms.games.APP_ID”

    android:value="@string/app_id" />

Could it be the reason why I am failing signing in? because it is slightly different.

Or Do I do something wrong during the build? 

I should also mention that I tried with a different code given by coronalabs on githubs:

https://github.com/coronalabs/plugins-sample-gameNetwork-google

Thanks again for anyone who could help me or even guide me 

In your build settings your googlePlayGamesAppId starts with a 15 and ends with a 16. The console log is finding a 53 and a 74 at the start and end. Which one is accurate?

You can always hand type that line just in case some non-ASCII characters got in there (like smart quotes, etc. The / is definitely weird.

We should be putting the right value in there and you should not need to modify it.

Rob

yeah sorry, because in my previous post I had a different app id, as I mentioned in the new one I have redone everything from scratch to be sure there was no mistake in it.

So the new app id is now starting with 53 and 74

my build setting is now : googlePlayGamesAppId =“53********74” (btw I am not sure how dangerous it is to write the whole app id on a forum :wink: )

I have also updated to the latest corona sdk build just in case but it did not make any difference.

My question is how can I change the manifest.xml file and  rebuilt everything to an apk file.

Do you think the problem is coming from the way I create the app on google play developer console. Cause to me it seems right.

I am getting  a bit lost now and not sure what I should do to get it right.

Thanks a lot for you help again.

Ok, I knew it was obviously something stupid on my side. I am a bit embarrassed to admit that but my email addresses for the google account on the dev console and on my phone were different. So I had to add a beta tester with the correct email address. 

and badaboum it worked !!! Can now see leaderboards and everything.

Thanks a lot for your help.

Cheers,

JJ