Android Automated Build Increment

I was looking for a way to automatically update the AndroidManifest.xml android:versionCode & android:versionName with a new build version everytime I compiled a new build.

I wanted to go from:

android:versionCode=”1″ android:versionName =”1.0.0″

to

android:versionCode=”2″ android:versionName =”1.0.1″ then

android:versionCode=”3″ android:versionName =”1.0.2″ etc.

Lots of googling found that there are complicated solutions using Ant, but there wasn’t a simple “do this” solution which took 2 minutes. The best solution I found was a recommendation to script it, so I did in C# .net 2 which was a 5 minute job, so as usual took an hour. So here let me save you an hour. “Do this”:

The Android Documentation for Versioning specifies that the versionCode should just be increased by one everytime there is a new build. This is an internal number just for you, other applications shouldn’t use it. The versionName is visible to other applications and has the format Major.Minor.Point. To me Point just means build and I just increment that value by 1. If you want to update the Major or Minor values, then just do it manually in the manifest. I guess you would do this just before releasing an update on the market.

One thing to watch out for.

If you change the versionName from “2.3.19” to “2.3.0” then when compiled it will become 2.3.1.

Instead change it to “2.3” and it will become “2.3.0”.

Also you will need .net2 installed. Pretty much everyone should have that already.