Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Google Play Games Services works when game is installed from apk, does not if installed from Play Store
Started by Loner Cat May 16 2018 06:15 AM

11 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Loner Cat

[GLOBAL: userInfoPane.html]
Loner Cat
  • Enthusiast

  • 33 posts
  • Corona SDK

Hi everybody.

I'm facing a problem that is making me crazy, maybe someone can help me.

 

The problem is with the gpgs.login function: if I install the game apk on my phone it works good, if I upload the exact same apk on google play (no matter if as open beta or close alpha) and install it, it stop working.

What happens is, the game shows the google play games panel as if it wanted to ask to choose an account, and then the panel just disappear and the login fails.

The error message it receive (event.errorMessage, as in the documentation) is "sign in failed" (code = 10002).

 

It's really driving me crazy, because it's the very same apk that works when installed from PC, with the same keystore, the same app id...

 

I thought of some possible cause:

1-User permission: but the app installed from the apk has the same permission and it works! Anyway the permission the game require are:

             "android.permission.INTERNET",
            "com.android.vending.CHECK_LICENSE",
            "android.permission.GET_ACCOUNTS",
            "android.permission.ACCESS_NETWORK_STATE",
            "android.permission.ACCESS_COARSE_LOCATION",
            "android.permission.WRITE_EXTERNAL_STORAGE"

2-Maybe I'm doing something wrong with the api management, but as required in the documentation I did enable Drive API and Google Play Developer API!

3-Something else??



[TOPIC: post.html]
#2

Loner Cat

[GLOBAL: userInfoPane.html]
Loner Cat
  • Enthusiast

  • 33 posts
  • Corona SDK

This is just ridiculous.

I just passed the entire day checking everything could be checked to see if it's ok, and everything seems to be just right. But when downloading the version from play store, it still doesn't access.

I'm really thinking about giving up this damned play games service al leave the game without it.

 

Thing I checked:

1-App ID: it's correct. I even tried to write it with and without the quotation marks, because I wanted to try everything...

2-SHA-1 key: it is correct, the same of the keystore I'm using to build

3-Licensing: I followed the guide to set it up, it seems correct to me. I initiated it in the main.lua file even if I don't care about using google anti piracy service. I tried to set this anti piracy setting on and off, no difference.

4-I've set on Google Drive Api and Google Play Android Developers API

 

Still working when installed from my PC, and not working when installed from Google Play. This is nonsense.

 

I'm posting part of my code, maybe you'll see some stupid error I'm not seeing.

 

Build.setting:


settings =
{

	plugins = {
        ["plugin.gpgs"] =
        {
            publisherId = "com.coronalabs",
            supportedPlatforms = { android=true }
        },
              },

	orientation =
	{
		-- Supported values for orientation:
		-- portrait, portraitUpsideDown, landscapeLeft, landscapeRight
		default = "portrait",
		supported = { "portrait", },
	},

	--
	-- Android section
	--
	android =
	{
		usesPermissions =
		{
			"android.permission.INTERNET",
			"com.android.vending.CHECK_LICENSE",
			"android.permission.GET_ACCOUNTS",
            "android.permission.ACCESS_NETWORK_STATE",
            "android.permission.ACCESS_COARSE_LOCATION",
            "android.permission.WRITE_EXTERNAL_STORAGE"
		},

		googlePlayGamesAppId = "249579054987",

		applicationChildElements =
        {
            [[
            <meta-data android:name="android.max_aspect" android:value="2.1"/>
            ]],
        },

	},

	--
	-- Project section
	--
	excludeFiles =
	{
		-- Exclude unnecessary files for each platform
		all = { "Icon.png", "Icon-*dpi.png", "Images.xcassets", },
		android = { "LaunchScreen.storyboardc", },
	},
}

config.lua:

application =
{
	content =
	{
		width = 1080,
		height = 1920, 
		scale = "letterbox",
		fps = 60,
		
	},

    license =
    {
        google =
        {
            key = "MII.. .  .  .  .  . . ..AQAB",
            policy = "serverManaged"
        },
    },
}



[TOPIC: post.html]
#3

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 681 posts
  • Corona SDK

It sounds like a licensing key issue.

 

Some questions:

1. Did you download the Prod key?

2. Are you set up for Google to manage the signing of your app?

3. When you sign it on your desktop are you using the prod key?

4. Can I download the app and test it out.



[TOPIC: post.html]
#4

Loner Cat

[GLOBAL: userInfoPane.html]
Loner Cat
  • Enthusiast

  • 33 posts
  • Corona SDK

It sounds like a licensing key issue.

 

Some questions:

1. Did you download the Prod key?

2. Are you set up for Google to manage the signing of your app?

3. When you sign it on your desktop are you using the prod key?

4. Can I download the app and test it out.

I'm not really sure about what do you mean in points 1, 2 and 3 :unsure:

I mean, what I did to set up the licensing is:

1-Put the requested permission in the build.setting file

2-Added a license table in the build file with my public key, that I got from the  services and APIs page on my developer's console

3-Just use the require("licensing"), licensing.init( "google" ) and licensing.verify() functions

 

From your question I guess I'm missing a lot of stuff and now feel kind of stupid :rolleyes:  but I just followed the instructions of the corona documentation!

Anyway sure you can download the app. You can download the beta version from google play from here https://play.google.com/apps/testing/com.lonercatgames.ripple or if you give me an email I can send you a more recent apk



[TOPIC: post.html]
#5

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 681 posts
  • Corona SDK

No, it is probably me. I am usually not very clear. It doesn't work on my phone either but it is a very cool game.

 

1. Let me start again. Where did you get the licensing key? Is should be under Google Play Console -> Your App -> Services & APIs & Licensing & In-App Billing.

2. Did you copy the entire string under config.lua:

application =
{
    
     license =
        {
            
                google =
                {
                    key = "yourKey",
policy = "serverManaged"
                }
        }
}

4. When you sign your app with corona what KeyStore and KeyAlias are you using? You should be using your real key and not debug.

5. In your build setting do you have the permission to check the license:

 

usesPermissions =

        {
            "com.android.vending.CHECK_LICENSE"
        }


[TOPIC: post.html]
#6

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 681 posts
  • Corona SDK

6. Did you any errors in the developers' console. You said you enabled Google Play Android Developers API? I have Google Play Game Services. It might be the same thing you mentioned.

 

This is what mine looks like:

 

Attached File  api.png   13.19KB   0 downloads



[TOPIC: post.html]
#7

Loner Cat

[GLOBAL: userInfoPane.html]
Loner Cat
  • Enthusiast

  • 33 posts
  • Corona SDK

No, it is probably me. I am usually not very clear. It doesn't work on my phone either but it is a very cool game.

 

1. Let me start again. Where did you get the licensing key? Is should be under Google Play Console -> Your App -> Services & APIs & Licensing & In-App Billing.

2. Did you copy the entire string under config.lua:

application =
{
    
     license =
        {
            
                google =
                {
                    key = "yourKey",
policy = "serverManaged"
                }
        }
}

4. When you sign your app with corona what KeyStore and KeyAlias are you using? You should be using your real key and not debug.

5. In your build setting do you have the permission to check the license:

 

Yes the key I'm using is the right one, the very long string found under services and APIs -> Licensing and in app billing. I also checked I put it right, without spaces and without cutting the first or last letter.

 

About the keystore, I'm using one I made with the java keytool, and I put the public signature on the google api console. And finally, I did put the license check permission in the build.setting file.

 

One thing that baffle me is that I just tried to replace the Sha1 digital signature on the api console with a wrong one, and the game still conects when installed from apk :huh: shouldn't it be refused by google? But maybe it will just take some time for google to process the changes. 

 

6. Did you any errors in the developers' console. You said you enabled Google Play Android Developers API? I have Google Play Game Services. It might be the same thing you mentioned.

 

This is what mine looks like:

 

Mine looks exactly like yours, except there are less requests. But no error reported.

 

Another thing that I don't understand is a message that appears in my corona console when building the app:

 

The signer's certificate is self-signed.

It's the only warning message I get when building, but I don't understand what it means.



[TOPIC: post.html]
#8

Loner Cat

[GLOBAL: userInfoPane.html]
Loner Cat
  • Enthusiast

  • 33 posts
  • Corona SDK

Another really weird thing: I tried to build the app with a wrong googlePlayGamesAppId in the build.setting. Result: it still works perfectly when installed from the apk.  This confirms my feeling that we're leaving the territory of the logic to enter in nonsense land.



[TOPIC: post.html]
#9

Loner Cat

[GLOBAL: userInfoPane.html]
Loner Cat
  • Enthusiast

  • 33 posts
  • Corona SDK

Ok I think I may have just found a solution. Now I'll test more to see if it's really working.

 

What I did is open the developer console, select my app under all apps and open the app signature panel. Then I notices that the SHA1 fingerprint provided in this page is different from the one I can extract from my keystore. I copied it and pasted in the api console instead of the one I took from my keystore, and now it seems to be working.

I still do not understand why the fingerprint certificate is different from the one I used to build the app, shouldn't it be the same? Anyway, for this time I'll embrace the philosophy of:

3e1.png


  • agramonte likes this

[TOPIC: post.html]
#10

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 681 posts
  • Corona SDK

That is what I was trying to get at with my first rambling post. Recently Google implemented this dual key idea. Similar to Amazon. You sign it with key A. They strip Key A from the file you upload and they sign it with Key B. I have both keys on my desktop. I usually test with Key B because it is the key that will end up in the store and then upload it signed with key A.



[TOPIC: post.html]
#11

Loner Cat

[GLOBAL: userInfoPane.html]
Loner Cat
  • Enthusiast

  • 33 posts
  • Corona SDK

That is what I was trying to get at with my first rambling post. Recently Google implemented this dual key idea. Similar to Amazon. You sign it with key A. They strip Key A from the file you upload and they sign it with Key B. I have both keys on my desktop. I usually test with Key B because it is the key that will end up in the store and then upload it signed with key A.

Well thanks for the help!

I was kind of going crazy ahah

Anyway, just one more thing. When you say you have bot keys on your desktop and you usually test with key B (google's one) you mean you can build the app using the deployment_cert.der file that you can download from the developer console?



[TOPIC: post.html]
#12

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 681 posts
  • Corona SDK

I think we are talking about the same thing. On my desktop, I have both the upload key (Key A) and the google signing key (Key B ). I test with Key B but I can't use that one to upload to Google.

 

I didn't download them. I don't know how to create a key.store from .der file. I created both keys and uploaded them to google.

 

Edit: I did find links online to convert that .der file to keystore. So it can be done and then you would have both keys like I have.

 

http://www.herongyang.com/Cryptography/Certificate-Format-keytool-Import-in-DER-and-PEM.html




[topic_controls]
[/topic_controls]