Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I was able to work out my own solution from the information given. In case it is useful for someone here is my bash script for updating the versionCode and versionName attributes when using the GIT VCS on Linux.</p></p> <p>My script to edit the AndroidManifest.xml file looks like this:</p> <pre><code>#/bin/bash CODE=`git tag | grep -c ^v` NAME=`git describe --dirty` COMMITS=`echo ${NAME} | sed -e 's/v[0-9\.]*//'` if [ "x${COMMITS}x" = "xx" ] ; then VERSION="${NAME}" else BRANCH=" (`git branch | grep "^\*" | sed -e 's/^..//'`)" VERSION="${NAME}${BRANCH}" fi cat AndroidManifest.template.xml \\ | sed -e "s/__CODE__/${CODE}/" \\ -e "s/__VERSION__/${VERSION}/" &gt; AndroidManifest.xml exit 0 </code></pre> <p>It parses the template file (AndroidManifest.template.xml) and replaces the strings "__VERSION__" and "__CODE__" with more appropriate values:</p> <ul> <li>"__CODE__" is replaced with a count of the number of tags in the Git repo which starts with a single lowercase V and is followed by a sequence of digits and dots. This looks like most version string like: "v0.5", "v1.1.4" and so on.</li> <li>"__VERSION__" is replaced with a combination of the output from the "git describe" command and, if not a "clean" build, the branch on which it was built.</li> </ul> <p>By a "clean" build I mean one where all the components are under version control and their is latest commit is tagged. "git describe --dirty" will report a version number based upon the last reachable annotated tag in your latest commit on the current branch. If there are commits since that tag a count of those commits is reported as is the abbreviated object name of your last commit. The "--dirty" option will append "-dirty" to the above information if any files are modified that are under version control have been modified.</p></p> <p>So AndroidManifest.xml should not be under version control any more, and you should only edit the AndroidManifest.template.xml file. The start of your AndroidManifest.template.xml file looks something like this:</p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.packagename" android:versionCode="__CODE__" android:versionName="__VERSION__" &gt; </code></pre> <p>Hope this is useful to someone</p>
 

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