I’m attending Mobile Product Development course at Haaga-Helia University of Applied Sciences taught by Tero Karvinen. The aim of the course is to build an own app. I have been building Personal Raineri app using Cordova CLI. The core functionalities of the app are ready, so I decided to publish app beta in Google Play Store to be downloaded freely.

To publish a package on Google Play Store you need to create a key, build a release APK file and sign it with the key. I noticed that Cordova can’t do this. The good news is, that all the needed tools are available, if one has Cordova CLI with support for building Android apps. So, at least in my case, nothing needed to be installed.

The documentation about signing a releasable APK was quite messy and fragmented but I was able to find all necessary information from official developer.android.com manuals. Creating the first release of an app requires three steps and after this everything works with a single command: ant release.

To achieve this heavenly state, one needs to create the key. I did it with the following command

keytool -genkey -v -keystore ~/.certs/personal_raineri_beta/personal_raineri_beta.keystore -alias personal_raineri_beta -keyalg RSA -keysize 2048 -validity 100000

Let me explain a bit. ~/.certs/personal_raineri_beta/personal_raineri_beta.keystore is the path I want to put the keystore file. I naturally also backed up this file, because I will need exactly the same key to release new versions of the app.

I also set personal_raineri as the alias (after -alias switch) of the app. I didn’t find out what that alias is and why is that needed, plus I didn’t have time to find it out, but I decided to name the alias descriptively instead of, say, aqwerawfawer.

One important thing is to set the validity value high enough. The validity period of the keystore file created with this command is 100000 days which is more than the minimum validity period requirement set by Google Play Store. Why would someone set the validity period shorter?

Anyway, pragmatically it’s enough to remember the path of the keystore file and the alias, because they need to be put in a config file. So the next step was to edit  ant.properties.

vim ~/cordova-projects/personalraineri/platforms/android/ant.properties

I added two lines there. The keystore file path and alias name are defined in the key creation command executed before.

key.store=/home/erkkimon/.certs/personal_raineri_beta/personal_raineri_beta.keystore

key.alias=personal_raineri_beta

Then I just moved to the app root of Personal Raineri and created the release APK. Please note that Android stuff is in subfolder of the Cordova Project. So when Android Documentation tells one to go to the project root directory, it doesn’t mean Cordova project root directory.

cd /home/erkkimon/cordova-projects/personalraineri/platforms/android

Then I executed the release APK creation command.

ant release

 The result was a releasable APK in platforms/android/bin.

ls ~/cordova-projects/personalraineri/platforms/android/bin/ | grep release.apk

PersonalRaineri-release.apk

 I already had an account in Google Play Store, so I just uploaded the APK to the service, added some descriptions, uploaded a few screenshots and did some settings. Now the package can be found here.

Share This