Initializing Games Client in Android

The question:

I’m trying the new Google Play Game Services.

At first I followed this howto https://developers.google.com/games/services/android/quickstart
and then finished this https://developers.google.com/games/services/android/init

I end up like this:

05-16 20:01:39.034: E/AndroidRuntime(18257): FATAL EXCEPTION: main
05-16 20:01:39.034: E/AndroidRuntime(18257): java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
05-16 20:01:39.034: E/AndroidRuntime(18257):    at com.google.android.gms.internal.p$f.a(Unknown Source)
05-16 20:01:39.034: E/AndroidRuntime(18257):    at com.google.android.gms.internal.p$f.a(Unknown Source)
05-16 20:01:39.034: E/AndroidRuntime(18257):    at com.google.android.gms.internal.p$b.p(Unknown Source)
05-16 20:01:39.034: E/AndroidRuntime(18257):    at com.google.android.gms.internal.p$a.handleMessage(Unknown Source)
05-16 20:01:39.034: E/AndroidRuntime(18257):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 20:01:39.034: E/AndroidRuntime(18257):    at android.os.Looper.loop(Looper.java:137)
05-16 20:01:39.034: E/AndroidRuntime(18257):    at android.app.ActivityThread.main(ActivityThread.java:5041)
05-16 20:01:39.034: E/AndroidRuntime(18257):    at java.lang.reflect.Method.invokeNative(Native Method)
05-16 20:01:39.034: E/AndroidRuntime(18257):    at java.lang.reflect.Method.invoke(Method.java:511)
05-16 20:01:39.034: E/AndroidRuntime(18257):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-16 20:01:39.034: E/AndroidRuntime(18257):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-16 20:01:39.034: E/AndroidRuntime(18257):    at dalvik.system.NativeStart.main(Native Method)

I’ve tried to follow the tutorial step by step. I don’t understand what is going wrong.

ava.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.

I thought that logcat = logs and there is nothing more. So where can I find these “logs”?

My implementation is different only in one thing. I have a ClassA which extends BaseGameActivity and then ClassB which extends ClassA and implements View.OnClickListener
So I have all methods from https://developers.google.com/games/services/android/init in class ClassB

Thanks for any help

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

I had the same problem initially. What I had to do was look at the full, unfiltered LogCat log. There, I saw the message:

GamesIntentService(17929): Using Google Play games services requires a metadata tag with the name “com.google.android.gms.games.APP_ID” in the application tag of your manifest

So, assuming you created an entry in your strings.xml called app_id, try adding the following to your AndroidManifest.xml under the <application> tag:

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

You can find your APP_ID in the Games Services tab

**Games Services** tab

Method 2

Complementing Hetabiquo response, if you also use Cloud Save service in your game you also must to update your application’s AndroidManifest.xml by adding the following meta-data tag inside <application> tag scope

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

Method 3

Just had the same issue but had the meta-tag correct – I did look up the unfiltered logcat and found out, that it was searching for a different meta-tag.

The name of the meta-tag differs by the sort of Client Number you submitted in the GameHelper Constructor (if you use it).

new GameHelper(this, GameHelper.CLIENT_GAMES);

For me I accidentaly used CLIENT_ALL which leads to a wrong expectations of the meta-tag name. I changed it to CLIENT_GAMES and everything worked smoothly.

Method 4

In addition to Hetabiquo, you can fin your APP_ID in the Games Services tab :

**Games Services** tab

Method 5

I suffered from this bug for quite some time. I decided to go through the basegameutils package scanning each file one at a time. In gameHelperUtils class i found this method, getAppIdFromResource(). Inside it it requested app ID from resource. I remembered I had hardcoded the app ID in the manifest file. I then added a string resource of app_id in the strings file. To my amazement, the error was gone and the leaderboard showed up!


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment