Do you find it hard to get a release build of an Android app? Well, you could say that it’s not at all difficult. It just takes about 1 minute to get a build, sign it with your release keys and you are done. For a typical moderately big Android app, you could have a QA process where you send out builds for testing or verification to someone else. And you could be sending out the builds multiple times a day. In such situations, it becomes a tad tedious getting release builds out of your eclipse. In this post, we will try to automate this process of preparing the release builds.
Our tool of choice is Ant. Most of you perhaps already know how to do set it up. We will, however, also see how to version or auto-label your builds in next post. In this post, we will go through the basics.
1. To start off with, create a “HelloWorldAnt” Android project.
2. The next step is to prepare our project to use Ant scripts. To do this, fire up your terminal, go to the directory where your project rests and type out this command.
android update project -p .
3. A few files would be added to your project. Among these, the build.xml is the file that Ant would read and package your apk.
Updated local.propertiesAdded file ./build.xml
Updated file ./proguard.cfg
4. Now try running this command in the terminal. After we setup everything, this is the one single command that we would run every time we need to create a release build.
5. You will see a long log of what Ant is doing. Look towards the end of the logs and you will notice these lines:
-release-nosign:[echo] No key.store and key.alias properties found in build.properties.[echo] Please sign /workspace/HelloWorldAnt/bin/HelloWorldAntActivity-unsigned.apk manually
[echo] and run zipalign from the Android SDK tools.
6. So, till this point, the Ant tool has prepared an unsigned apk which it has kept in the bin folder of your project and it asks you to manually sign this apk with your release keys. Next step is to automate this process.
7. Put your keystore inside your project folder. For this project, sample_keystore is the keystore that we would be using to sign this application. Now, we need to tell Ant to use this keystore to sign our builds with. Here, we will add a few files to our project.
8. At this point, if you try running “ant release” command, it will ask you to enter the password for the keystore and the alias name, and finally, it would put the release and signed builds in your bin folder.
The next post will talk about customizing the build process to the next level.