Tricks to Fix Google Play Service Bugs
Registering a game in the Google Play service may seem mistakenly easy. However, users come across some pitfalls. This article is a short guide on how to fix Google Play service errors.
First of all, you should read the Google tutorial. After reading this guide you may try to register a project example from that tutorial. You hope to see your program leaderboard, but instead…. “Unknown error”. You are asking yourself: “Oh Jesus, what have I done wrong?!” You are looking for an answer in the tutorial but can’t find it. After several hours of fruitless search you realise that the answer cannot be found anywhere. You call the wrath of gods upon the heads of the Google programmers who played this joke about the service and documentation. Breathe in. Let’s figure out together what is wrong.
The unclear message with an unknown error appears. That’s why we’ll be better off looking into the program logs. We will see a more detailed message regarding the error in the LogCat. However, you should note that the message tag is different from your program’s tag. This message contains human readable text and the error code. The text can provide us with information about what has actually happened. Our program has not been registered.
Now let’s switch from the Developer Console to the Google APIs Console page. We can see that, basically, only namespace and SHA1 hash are used for program registration. We can say with confidence that the namespace of our program has not been changed, so SHA1 has to be the problem. Let’s compare the SHA1 hash that is shown in the Developer Console to the program’s hash to see if they are actually different. We can get the program hash using the “keytools” utility, or, if you are using the ADT latest version, you can see it when you are signing your program. So let’s compare two SHA1. Just as we predicted they are different. So the problem is that the SHA1 hash of our program is not calculated correctly by the Developer Console. Let’s replace it with a correct one during the registration process. Now let’s start the program again and … Voila! We see the light – I mean our program’s leaderboard!
Note 1: this information is relevant to Monday, June 3rd. It might be that by the time you read this article, Google will have already fixed this bug.
Note 2: A little bonus for guys who are using Cocos2d-x framework. You can use the Google Play service through JNI. Just implement the BaseGameActivity abstract class and its methods. They are clearly named and you can figure out what they do without any effort. Simply call these class methods through the JNI and that’s it.