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