Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have done this with a ton of custom ant steps.</p> <p>First, you need to extract the build number into a properties file. Let's call it <code>version.properties</code></p> <p>Then, the step to increment the version code is:</p> <pre><code>&lt;target name="increment-version-code"&gt; &lt;propertyfile file="version.properties"&gt; &lt;entry key="versionCode" type="int" default="0" operation="+" value="1" /&gt; &lt;/propertyfile&gt; &lt;/target&gt; </code></pre> <p>This will read the entry <code>versionCode</code>, increment it and save it back to version.properties.</p> <p>So far, so good. The last step is to get that <code>versionCode</code> into the <code>AndroidManifest.xml</code> file and unfortunately now it gets messy.</p> <p>The way I solved it was to regenerate the manifest from a template on every build using the <a href="http://ant.apache.org/manual/Tasks/filter.html" rel="nofollow">filtering functionality</a> in ant.</p> <pre><code>&lt;target name="generate-manifest"&gt; &lt;filter filtersfile="version.properties"/&gt; &lt;copy todir="${source.dir}" overwrite="true" verbose="true" filtering="true"&gt; &lt;fileset dir="${source.dir}" casesensitive="false"&gt; &lt;include name="**/*.base"/&gt; &lt;/fileset&gt; &lt;mapper type="glob" from="*.base" to="*" /&gt; &lt;/copy&gt; &lt;/target&gt; </code></pre> <p>Then, all you have left to do is move your AndroidManifest.xml to AndroidManifest.xml.base and replace your <code>versionCode</code> attribute to read <code>android:versionCode="@versionCode@"</code> . You can then run the <code>increment-version-code</code> target to bump the versionCode in <code>version.properties</code> and the <code>generate-manifest</code> target to convert the <code>.base</code> template into the final manifest.</p> <p>These can then be easily added as build steps to your Eclipse project or as dependencies to exported ant builds. Unfortunately, there's no easy hook for the Export functionality (though, there is for "After Clean", which I find good enough).</p> <p>Of course, with Gradle on the horizon, all of this would have to be rewritten soon. <code>:(</code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload