Google Play Game Services - unable to sign in

Right after yesterday's Google I/O keynote I've updated my Android SDK to integrate the game services into one of my apps.

Things I've done so far:

  1. added and linked my app in the Dev Console (game services)
  2. included the OAuth client id into my app/manifest
  3. added BaseGameActivity and GameHelper to my project (from GitHub)
  4. added the google-play-services library to my project
  5. extended BaseGameActivity, added a com.google.android.gms.common.SignInButton

I've also set up game meta data and, of course, some achievements. The dev console states that it is ready to release. To test the login flow and achievements, I've added two Google+ accounts as test users.

But when I test the SignInButton, an alert pops up: Unknown error. Here's the logcat:

ERROR/Volley: il.a: Unexpected response code 403 for https://www.googleapis.com/games/v1/players/me
ERROR/SignInIntentService: Access Not Configured
ERROR/LoadSelfFragment: Unable to sign in - application does not have a registered client ID

I've built my application in production mode - using ProGuard and the right certificate.

Did I miss something?

Update - some more attempts

Here's a short overview about what I've tried in the meantime. Nothing helped.

  • remove and recreate the linked Android app entry (double checked certificate fingerprint)
  • disable anti-piracy
  • skip proguard
  • create a new (test) game and use its client id

The problem is not related to the accounts for testing section. Using an account which is not enabled for testing will lead to another error message:

E/GameAgent: Unable to retrieve 1P application 547xxxxxx457 from network
E/CheckGameplayAcl: Unable to load metadata for game

Solution by Hartok!

Hartok's solution helped me a lot to fix this issue. I've never visited the Google APIs Console before. It's important to know, that the OAuth Client ID is not deleted when you remove a linked app from your game or even delete a game (in the Dev Console). You have to visit the APIs Console and remove it manually.

The auto-selected SHA1 fingerprint is (always) wrong! You have to lookup your own:

keytool -exportcert -alias <your-alias> -keystore <path-to-keystore> -list -v

The new client id of my (correctly) linked app looked like 89xxxxxxxx73-2u6mXXXXXXXXXXXXXXXXXXX8903.apps.goo..., not just 12 digits as before. I finally figured out that you have to exclude the dash and alphanumeric stuff and have to use the 12 digits only.


Solution 1:

I've fixed this issue.

In my case, when I've linked my app (not yet published) to my Google Play Game Services project, the Certificate Fingerprint auto-selected by Google Play was not the good one.

To fix that, I've deleted my app client ID on Google APIs Console, unlinked my app, then relinked it with the proper Certificate Fingerprint. This Fingerprint is displayed when exporting your app in Eclipse (if your ADT plugin is up-to-date).

Hope it helps.

Solution 2:

Had the same problem. My solution was to link the same package twice in the Dev Console, the first using the SHA1 fingerprint from my own certificate and the second using my debug key SHA1.

I had tried using just one or just the other before this and it hadn't worked for either.

Solution 3:

After a long 2 weeks trying to fix this problem I have created steps for me to resolve this problem, and decided to share it with every one who is suffering from the same issue, this comes without publishing the game . it is used for testing. when publish time comes I will share the steps used to publish the app and make sure it works with Google play game service.

note that all I was trying to do is sign in using the Google sign in button with no action as to what should happen after sign it, also note that I have used BaseGameUtils from the Google play example as a library, and my IDE of choice to get all of this done was Eclipse.

Below are the steps one by one using eclipse:

1-import BaseGameUtils as a library in your eclipse work space, make sure no error occurs after the import. if an error occurred do the following:

a- right click on the BaseGameUtil project in project explorer

b-Click on Java build path

c-Click add external jars from there navigate to your SDK location and find Google-Play-services.jar

d-select it and click ok ---> you should see the jar added in the JARs and class folders window.

e-Go to the Order and export tab, on the right hand side of libraries and make sure "Android private libraries" and "Android Dependencies" are checked also ensure that the google-play-services.jar is selected.

2- Now make sure you reference your imported BaseGameUtility correctly in the app you want to use ," You can Create a simple hello world application to test this " , so now we will reference the BaseGameUtility in the hello world application as follows:

(important ensure Both hello world and BaseGameUtil are both in the same drive two drives will not work)

a-right click on the hello world application in the right hand side in project explorer

b-click on Java build path

c-Click on Libraries

d- add the android support-v4 if needed from an external or internal source (Not Required)

e- add the base game utils .jard by clicking on add class folder --> then select the BaseGameUtilProject ---Then select the /bin folder --This should import it to your application

f-add google-play-services.jar from an external source also if needed

g-in "order and export" ensure that you have the following selected --->"Android Private Libraries,Android dependancies ,BasegameUtils.jar,GooglePlayGameServices.jar" along with the normal SRC and GEN that should be selected by default.

3- now in your java file helloworld.java ensure that your main screen has all the required imports and then extend the BaseGameUtil and make sure the project implements the ViewOnClickListener.

4- Edit your android manifest to include the following:

 <meta-data android:name="com.google.android.gms.games.APP_ID"
        android:value="@string/app_id" />

and

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

5- ensure that you have a ids.xml file in your resource to include your application ID after you create it.

<string name="app_id"></string>

You can leave it blank for now as later you will have to place the application ID in it

6-copy the debug key you have on your eclipse IDE before you add this application in the developer console. doing so in eclipse happens as follows:

a-click on Window b- select android c-Click build d- copy the SHA1 fingerprint and keep it to use it when creating your app in Developers console.

7- Create your game in developers console and use the SHA1 retrieved from step 6.

8- place the application ID in the ids.xml highlighted in step 5

9- double check your values and ensure that the package names are all correct between the developers console and the manifest file .

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
**package="com.helloword.check"**
android:versionCode="1"
android:versionName="1.0" >

10- When done ensure that the application in the developer console matches the SHA1 that is assigned in developer console using the keytool. This is the step that took me 2 weeks just to figure out

a- locate your application APK from the bin folder of your hello world project, and copy it to another location to check its ID with key tool later

b-locate your keytool --> usually located under the JAVA folder of your computer, in my case it was under C:\Program Files\Java\jdk1.7.0_09\jre\bin

c- Extract your apk in the temp location

d- run the following command

keytool -printcert -file "TempLocation\Meta-INF\CERT.RSA"

you will get an MD5 along with SHA1 and SHA256

Ensure that the SHA1 matches the one in the developers console.

11- Here is how to check your SHA1 from developers console,

a- go to Game Services

b- click the name of the game in our case helloWorld

c- Scroll down to "API Console Project"

d- You should see " this game is linked to the API console Project called helloworld"

e- helloworld should be a hyperlink click it,

f- this will open the Google APis Console

g- in APconsole click on API Access

h- scroll down to "Client IDs for installed application" , you should see the SHA1 ensure it is the same as the one generated from the keytool earlier in step 10 . ( if they don't match you have to delete the game from developers console and recreate it with the correct SHA1 ) " make sure not to change the SHA1 from Google APIs console this will cause issues.

I-Ensure the package name is the same package name in your android manifest, by that I mean everywhere package name is mentioned ensure it matches the one in " Client ID for installed applications" ( in my case it didn't match the one in the line 4 of my manifest)

And that is it you should now be able to test your sign in using google play game service

Solution 4:

In Step 3. Generate an OAuth 2.0 client ID it specifically gives a warning as follows:

Warning: Do not open the Google APIs Console directly and manually add your Client IDs on that page. Doing so might cause errors when you send requests to the game services.

So my experience was that you need to follow the guide religiously: Setting Up Google Play Game Services with the Google Play Developer Console

Solution 5:

I was fighting this problem a lot. Changes in Google APIs Console only break OAuth Client ID- don't touch it. The only solution for me was to create new game service and connect signed apk with normal(not debug) key- because once you add apk with any key, if you will try again to add it with different key it will not work. Deleting game will not work, google will still remember the package name. You can try to change apk package name (of course it is not the best idea) and try again but it is not always work.

So once you will have this problem the best solution is to change apk package name and create new game service - this for sure always work- and please be careful with the game service name - don't make it with name you used earlier - it will mess up everything.

From few problems I have got with this service the funniest is that I now have my apk connected with game service but it is not listed in it and I cannot add it because of an error:This client ID is globally unique and is already in use- I think that client ID is not an OAuth ID - I cannot delete it - there is no such option- and maybe this is a root problem of what we got here.