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.
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.Updated local.propertiesAdded file ./build.xmlUpdated file ./proguard.cfg
ant release5. 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.
key.store=sample_keystore8. 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.
Automating Builds on Android - Part 2
You can find the sample project here.