November 22, 2016

The following is a simple technical guide to help developers to publish their Android app on Google Play.

Here is what you need :

A Google Play publisher account (which is mainly an Android developper account). You can sign up from here

Android Studio in order to generate your .apk file (the Android Application Package is a package file format used to distribute and install apps on Android)

If you are ready to publish, let’s see how to generate your apk. In Android Studio, access “Build” and then “Build apk” from the top menu :

Your application folder now contains a file called app-debug.apk :

From the command line, change directory to where your app-debug.apk file is located. Once there, we need to generate a key that will help us signing the apk. In the command line terminal, type the following :

keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

Create a password for the keystore (mandatory) and on the last question, type yes :

We notice a new file created in our folder, the keystore file :

We’ll use the keystore file to sign the application by typing the following command:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore app-debug.apk alias_name

The next step is optimizing the apk. The result is having the app use less RAM when running. We’ll use the zipalign tool. It’s usually found under /path/to/Android/sdk/build-tools/VERSION/zipalign. On a mac, it is under ~/Library/Android/sdk/build-tools/VERSION/zipalign :

~/Library/Android/sdk/build-tools/yourVersionOfAndroid/zipalign -v 4 app-debug.apk new-optimized.apk

We notice a new file created in our folder, the new-optimized apk .

Done! Now you can now go to https://play.google.com/apps/publish/ and upload your apk.

Once it got accepted, you can later publish new versions of your app. You’ll have to change its version in the manifest.xml file before submitting it (notice lines 3 and 4)

Then, you can simply resign the apk:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore app-debug.apk alias_name

Optimize it once more :

~/Library/Android/sdk/build-tools/yourVersionOfAndroid/zipalign -v 4 app-debug.apk new-optimized.apk

And then from the left menu “APK”, “Upload new APK to Production” and then upload:

Done!

If any questions or suggestions, send me a tweet at @dandancrisan or let’s go for coffee in SF or Montreal . Thanks for reading and I hope it helped ! (:

20 Kudos