Android keystore for Google Play Game Service (GPGS)

I have configured GPGS in Google Play Developer Console and added my Corona Android game to “Linked apps”.
 
gpgs.login() fails with:
 
[lua]03-16 20:22:13.912 18468 18488 I Corona  : GPGS login error message: sign in failed
03-16 20:22:13.912 18468 18488 I Corona  : GPGS login error code: 10002[/lua]

This could be caused of a “wrong” Keystore as far as I know. But how can I generate a valid Keystore to be able to test GPGS on my devices?

Found this documentation:

Result code sent back to the calling Activity when signing in fails. The attempt to sign in to the Games service failed. For example, this might happen if the network is flaky, or the user's account has been disabled, or consent could not be obtained. Constant Value: 10002

Thanks,

Michael

I don’t know if it is only caused by wrong keystore but if that’s the case, you should sign your .apk with a keystore othen than the debug keystore.

https://docs.coronalabs.com/guide/distribution/androidBuild/index.html#build-process

I did not build it with the debug keystone but with a keystore that I also use to upload my apk to Google Play Developer Console.

So if I can upload my apk there it should be a valid keystore for Google Play Game Services as well?

Yes, it should be. You might be missing a point in the docs. Are you using the latest GPGS plugin or the legacy one?

Ok strange… I am using the latest GPGS plugin.

Can you share the related parts of code from build.settings and your code so we can have a sense of what’s going on? Don’t forget to replace your IDs with fake ones.

build.settings (relevant parts)

    ["plugin.gpgs"] =     {       publisherId = "com.coronalabs",             supportedPlatforms = { iphone=true, android=true }     } android = { googlePlayGamesAppId = "myAppId", usesPermissions = { "android.permission.INTERNET", "com.android.vending.CHECK\_LICENSE" }, },

config.lua

 license = { google = { -- The "key" value is obtained from Google key = "Key from Play Developer Console", -- The "policy" key is optional; its value can be either "serverManaged" (default) or "strict" -- A value of "serverManaged" will query the Google server and cache the results (this is similar to Google's "ServerManagedPolicy") -- A value of "strict" will not cache the results, so when there's a network failure, the licensing will fail (this is similar to Google's "StrictPolicy") policy = "serverManaged" }, },

main.lua

local function gpgsInitListener(event) print("GPGS init: " .. event.name) if event.isError then -- Failed to verify app from the Google Play store; print a message print("GPGS init error message: " .. event.errorMessage) print("GPGS init error code: " .. event.errorCode) else print("GPGS init succeeded") end end gpgs.init(gpgsInitListener)

login code

 local function loginListener(event) if event.isError then -- Failed to login to Google print("GPGS login error message: " .. event.errorMessage) print("GPGS login error code: " .. event.errorCode) else print("Successfully logged in to Google") showLoginButton(false) end end gpgs.login({userInitiated = true, listener = loginListener})

It now works but unfortunately I am not sure why :o

I think I linked not the correct project in Google Play Developer Console to https://console.developers.google.com/apis/

Thanks for your support.

I’m glad it works. Good luck :slight_smile:

I don’t know if it is only caused by wrong keystore but if that’s the case, you should sign your .apk with a keystore othen than the debug keystore.

https://docs.coronalabs.com/guide/distribution/androidBuild/index.html#build-process

I did not build it with the debug keystone but with a keystore that I also use to upload my apk to Google Play Developer Console.

So if I can upload my apk there it should be a valid keystore for Google Play Game Services as well?

Yes, it should be. You might be missing a point in the docs. Are you using the latest GPGS plugin or the legacy one?

Ok strange… I am using the latest GPGS plugin.

Can you share the related parts of code from build.settings and your code so we can have a sense of what’s going on? Don’t forget to replace your IDs with fake ones.

build.settings (relevant parts)

    ["plugin.gpgs"] =     {       publisherId = "com.coronalabs",             supportedPlatforms = { iphone=true, android=true }     } android = { googlePlayGamesAppId = "myAppId", usesPermissions = { "android.permission.INTERNET", "com.android.vending.CHECK\_LICENSE" }, },

config.lua

 license = { google = { -- The "key" value is obtained from Google key = "Key from Play Developer Console", -- The "policy" key is optional; its value can be either "serverManaged" (default) or "strict" -- A value of "serverManaged" will query the Google server and cache the results (this is similar to Google's "ServerManagedPolicy") -- A value of "strict" will not cache the results, so when there's a network failure, the licensing will fail (this is similar to Google's "StrictPolicy") policy = "serverManaged" }, },

main.lua

local function gpgsInitListener(event) print("GPGS init: " .. event.name) if event.isError then -- Failed to verify app from the Google Play store; print a message print("GPGS init error message: " .. event.errorMessage) print("GPGS init error code: " .. event.errorCode) else print("GPGS init succeeded") end end gpgs.init(gpgsInitListener)

login code

 local function loginListener(event) if event.isError then -- Failed to login to Google print("GPGS login error message: " .. event.errorMessage) print("GPGS login error code: " .. event.errorCode) else print("Successfully logged in to Google") showLoginButton(false) end end gpgs.login({userInitiated = true, listener = loginListener})

It now works but unfortunately I am not sure why :o

I think I linked not the correct project in Google Play Developer Console to https://console.developers.google.com/apis/

Thanks for your support.

I’m glad it works. Good luck :slight_smile:

I cannot get the login to succeed. I have tried enabling all the required google apis and following the tutorials. No matter what I do, it always returns “sign in failed” on the login. I don’t know what else to do at this point.

Can you tether your device to your computer and use “adb logcat” to capture the console log while you urn your app. Please don’t add any filters. This will produce large log file full of irrelevant items, but we need to see messages from multiple activities/processes. 

Also please post your code you’re using to login with.

Finally please post your config.lua.

Rob

I cannot get the login to succeed. I have tried enabling all the required google apis and following the tutorials. No matter what I do, it always returns “sign in failed” on the login. I don’t know what else to do at this point.