Build Numbers in Android Applications

Posted: September 23, 2009 in Android, Java, Mobile
Tags: , ,

When working with new innovative technologies you often have to take apart old tools and gleu them back in new ways to deal with new issues. If you have worked in JavaMe(j2ME) before you might have used something like JReleaseInfo to adjust and collate different manifest items to add to the manifest before you jar’d it such as the build number. However, in the Adnroid Java Application development world the manifest is no longer an *.Mf file but an XML file and thus the version number we have to change upon calling an ANT task such as build number is in that file.

I came up with:

<!-- Set build number -->
<condition property="">
<available file="build.number"/>
<equals arg1="${}" arg2="false"/>
<!-- We know build.number will set to 1 at <buildnumber/> call
<!-- Set var build.number.initial to build.number-1 -->

<equals arg1="${build.number}" arg2="1"/>
<!-- do not change AndrodManifest -->
<!--- okay do our repalce thing on AndoridManifest.xml -->
<property name="android.version.code" value="android:versionCode="/>
<property name="" value="android:versionName="/>
<replaceregexp file="androidManifest.xml"
<replaceregexp file="AndroidManifest.xml"

The way I came up with is:

1. check to see if build.number file exists, rember the build.number property is incremented from zero to 1 on first <buildnumber/> ant task call.

2. if false than cal <buildnumber/> task

3 if true than check to see if build.number is 1 and if so do not change AndroidManifest.xml and if not change to relfect new build number.

Reblog this post [with Zemanta]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s