Sunday, July 28, 2013

Signing and zip Aligning Android .apk file

Since I just released a new Android version of Monster Cache, this confusing process is fresh in my mind.  So I thought I'd jot it down for reference later, and for others.

When you want to upload a .apk file to the Google Play store, it has to be signed and zip aligned.  The .apk that Eclipse normally generates and that I send to people for testing can not be uploaded.  Instead, you have to follow these steps to prepare the .apk for uploading

1) You have to set android:debuggable="false" in your AndroidManifest.xml before you can create the signed .apk.  So do that first.

2) In Eclipse 3.7.2, choose File/Export...

3) The first part of the wizard shows a list of folders.  Choose "Export Android Application" in the Android folder

4) In next step, browse to select your project.  At this point, you'll get a warning if your manifest is still set to allow debugging.  Otherwise, it should say "No errors found.  Click Next"

5) This is the confusing part.  A keystore is a password protected file that holds keys that each have their own password.  So if you need to make a keystore, choose "Create new keystore" and choose a location for it and a password for the keystore file itself.  Then you'll create the internal key (aka alias?) and give it a password too.  If you've already created one, then just specify its location here and type in its password.  The rest of these steps assume you had an existing keystore.

6) Once you type in the password for your key store, choose your Alias/Key and type in its specific password

7) Last step of the wizard is to specify the location for your signed .apk file.  I name mine with the version and Signed, like MonsterCacheV120Signed.apk

8) The .apk file still needs to be zip aligned.  The zipalign.exe file is somewhere in the Android SDK folder. Sorry, I don't remember where.  I copy it to the same folder as my .apk file

9) Open a command prompt in folder where you have the .apk file and the zipalign.exe

10) Run this command
zipalign 4 <infile> <outfile>
So for example
zipalign 4 MonsterCacheV120Signed.apk MonsterCacheV120SignedAligned.apk

11) Now you have a signed and aligned file that can be uploaded to the Play store

No comments:

Post a Comment