Saturday, July 2, 2016

Corrupted Android keystore file

Last week I ran into situation where I noticed that my Android Keystore file used for signing e.g. Battlecards game was somehow corrupted. Obviously, I had  not done any backups of my keystore file, so there was no way to fix it. So I decided to generate new keystore and compile my app again with cocoon.io.

But that was not so easy: After cocoon.io compilation was finished, I was not able to load new .apk to my testing device. Tablet complained that previous version of app has been signed using different key and refused to install new version. So I removed old version of Battlecards from tablet, and realized that I had to do same for all my test accounts that were created to that tablet. Only then I was able to install new version (signed with new key).

After some struggling I was able to install new version generated with new keystore file and started the app. But then I noticed that all Google Play Game Services, including leaderboards, achievements, etc. were not working at all with new .apk. Now I understood that I was not able to publish updates for Battlecards with the new keystore. Great.

Needless to say, I tried to find some solution for this situation desperately. But I soon came into conclusion that only feasible way for me was to publish Battlecards as a new application and use new keystore for further updates. So I created new application to Google Play, filled all required fields, uploaded new .apk (signed with new keystore), and finally created new application entry to Google Play Game Services. This took about 1 hour for me, so after all it was not so big task. It was mostly copy&paste from old app entries.

You have also keep in mind that same package name can't be used for two apps, because they must to be unique. For example, Battlecards original package name (old keystore) was "com.gamaan.battlecards", and the new package name is "com.gamaan.battlecard". So there is just the difference of one character in package names.

Luckily, there were not yet too many downloads for Battlecards, so informing existing players was not too big problem. But if there were thousands (or millions) of active players for a game, then it would be wise to find a way to tell them to download new version.

And what was the root cause for keystore corruption? I can not say for sure, but I suspect it had something to do with the Android Studio version update I did some time ago. I googled this a bit, and found out that there are some other people whose keystore were broken after updating to newer Android Studio or JDK version. So maybe that is the reason?

Anyways, I strongly suggest you to have a backup or two of your Android keystore file. That might help resolving this kind of a situation. :)

-Jussi

PS. If you run into similar situation and want try to recover your corrupted keystore, this article might be a good startpoint to get deeper understanding what is going on.

No comments:

Post a Comment