How to use Ant to build Android applications
I was trying to add (re-add) the feature to let users generate their very own POSIT versions. It used to be there when I was working on it initially and I’d completed it reasonably last summer. The idea was chucked away as we moved on. But, now we wanted it back.
The first thing to do in a case like this, is to figure how to compile an apk. One of the criterias I’ve put for myself is, this program absolutely must work (in 1.0 I mean
) without internet connection also as POSIT is supposed to be used for disaster recovery.
Ok. Let’s get down to business, the first time I’d implemented this, I had a django webapp (we have php now, 3rd rewrite) that would exec ‘ant build’ to generate a custom POSIT app.
Thanks to subversion, I was able to grab that build.xml from the old code. As naive as we programmers can sometimes be, I really did think this would work.. somewhat, maybe 20 mins tops.. lol
But, with new versions, things have changed a lot, we don’t have R.java in src folder and a lot of the tools aren’t in same place or accept the same arguments, notably aapt tool.
After fumbling for an hour or so trying to created a build.xml that worked, I felt.. hey, this is Google, I bet they thought of this and have a tool. ( I did try to search for activitycreator.py that was used to generate a generic build.xml file)
And lo and behold…
I read the Manual…. http://developer.android.com/sdk/1.5_r1/upgrading.html
It said that the new tool ‘android’ can be used to create the build.xml automatically…
android update project --path /path/to/my-project --target 1
As easy as that! Of course, the target needs to be >3 if you want your precious Google Maps to work.
Moral: Read the Manual… really really read it… ASAP












