Better than using replaceregexp, I'd suggest the following XSLT script, using Ant's xslt task.
(Mine is much more complex -- tweaks metadata, removes unneeded broadcast listeners in different versions, etc. Once you get this basic script in place, it's easy to add additional modifications). <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version=".0" xmlns:android='http://schemas.android.com/apk/res/android' > <xsl:param name="VERSION"/> <xsl:param name="VERSIONNAME"/> <xsl:output indent="no"/> <!-- Start with a newline --> <xsl:template match="/"> <xsl:text> </xsl:text> <xsl:apply-templates select="@*|node()"/> </xsl:template> <xsl:template match="/manifest/@android:versionCode"> <xsl:attribute name="android:versionCode"><xsl:value-of select="$VERSION"/></xsl:attribute> </xsl:template> <xsl:template match="/manifest/@android:versionName"> <xsl:attribute name="android:versionName"><xsl:value-of select="$VERSIONNAME"/></xsl:attribute> </xsl:template> <!-- Identity transform by default --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> Then this ant task invokes it: <xslt in='${loc.project}/AndroidManifest.xml' out='${loc.project.build}/AndroidManifest.xml' style='configureManifest.xsl' force='true'> <param name='VERSION' expression="${BUILD}"/> <param name='VERSIONNAME' expression="${VERSIONNAME}"/> </xslt> (This copies it from the checkout tree to the production build area, with the modifications). There are a number of issues with using ant's buildnumber facility. I really don't recommend it. What I do is to tag each production build in Subversion, and use the subversion revision number as a build number. <svn javahl='${use.javahl}' svnkit='${use.svnkit}'> <info target="${svn.source.root}" propPrefix="svn.info" verbose="true"/> </svn> <property name='BUILD' value='${svn.info.lastRev}'/> I've used this technique for build systems for several companies as well. It has always worked out well. On Aug 8, 7:28 am, Leigh McRae <[email protected]> wrote: > Use the ant task replaceregexp to find and replace the values in > AndroidManifest.xml. Also there is an ant task to maintain a build > number, I forget the name. > > On 8/7/2010 11:05 AM, samspade79 wrote: > > > Hi, > > > Does anyone know a way I can have my ant build automatically increment > > the version number in the AndroidManifest.xml file ? > > -- > Leigh McRaewww.lonedwarfgames.com -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

