Next: , Previous: Repo, Up: Metadata


7.14 Build Version

Any number of these fields can be present, each specifying a version to automatically build from source. The value is a comma-separated list. For example:

Build Version:0.12,3,651696a49be2cd7db5ce6a2fa8185e31f9a20035

The above specifies to build version 0.12, which has a version code of 3. The third parameter specifies the tag, commit or revision number from which to build it in the source repository.

If the commit version starts with a !, that version is not built. Instead, everything after the ! is used as a reason why it can't be built. The purpose of this feature is to allow non-buildable releases (e.g. the source is not published) to be flagged, so the scripts don't generate repeated messages about them. (And also to record the information for review later).

In addition to the three, always required, parameters described above, further parameters can be added (in name=value format) to apply further configuration to the build. These are:

subdir=<path>
Specifies to build from a subdirectory of the checked out source code. Normally this directory is changed to before building,
bindir=<path>
Normally the build output (apk) is expected to be in the bin subdirectory below the ant build files. If the project is configured to put it elsewhere, that can be specified here, relative to the base of the checked out repo.
oldsdkloc=yes
The sdk location in the repo is in an old format, or the build.xml is expecting such. The 'new' format is sdk.dir while the VERY OLD format is sdk-location. Typically, if you get a message along the lines of: "com.android.ant.SetupTask cannot be found" when trying to build, then try enabling this option.
target=<target>
Specifies a particular SDK target, when the source doesn't. This is likely to cause the whole build.xml to be rewritten, which is fine if it's a 'standard' android file or doesn't already exist, but not a good idea if it's heavily customised.
rm=<relpath>
Specifies the relative path of file to delete before the build is done. The path is relative to the base of the build directory - i.e. the root of the directory structure checked out from the source respository - not necessarily the directory that contains AndroidManifest.xml.

Multiple files can be specified by separating they with ';'.

antcommand=xxx
Specify an alternate ant command (target) instead of the default 'release'.
forceversion=yes
If specified, the package version in AndroidManifest.xml is replaced with the version name for the build as specified in the metadata.

This is useful for cases when upstream repo failed to update it for specific tag, or to build an arbitrary revision.

forcevercode=yes
If specified, the package version code in the AndroidManifest.xml is replaced with the version code for the build. See also forceversion.
update=xxx
By default, 'android update project' is used to generate or update the build.xml file. Specifying update=no bypasses that.

Specifiying update=force forces rebuilding of the build.xml file at the same time - this is frequently needed with r14 of the Android platform tools. Be aware of any customisations in build.xml when using update=force.

Otherwise, value can be a semicolon-separated list of directories in which to run 'android update project' relative to the main application directory (which may include 'subdir' parameter). Default value is '.', and passing non-default value may be useful for multi-component projects. Note that --subprojects switch is automatically passed to 'android update project', so using explicit list may be needed only for peculiar source layouts.

initfun=yes
Enables a selection of mad hacks to make com.funambol.android build. Probably not useful for any other application.
buildjni=[yes|no|<dir list>]
Enables building of native code via the ndk-build script before doing the main ant build. The value may be a list of directories relative to the main application directory in which to run ndk-build, or 'yes' which corresponds to '.' . Using explicit list may be useful to build multi-component projects.

The build and scan processes will complain (refuse to build) if this parameter is not defined, but there is a jni directory present. If the native code is being built by other means, you can specify no here to avoid that. However, if the native code is actually not required, remove the directory instead (using prebuild for example).

scanignore=path1;path2;...
Enables one or more files/paths to be exlcuded from the scan process. This should only be used where there is a very good reason, and probably accompanied by a comment explaining why it is necessary.

When scanning, files whose relative paths start with any of the paths given here are ignored.

submodules=yes
Use if the project (git only) has submodules - causes git submodule init and update to be executed after the source is cloned.
encoding=xxxx
Adds a java.encoding property to local.properties with the given value. Generally the value will be 'utf-8'. This is picked up by the SDK's ant rules, and forces the Java compiler to interpret source files with this encoding. If you receive warnings during the compile about character encodings, you probably need this.
prebuild=xxxx
Specifies a shell command (or commands - chain with &&) to run before the build takes place. Backslash can be used as an escape character to insert literal commas, or as the last character on a line to join that line with the next. It has no special meaning in other contexts; in particular, literal backslashes should not be escaped.

Note that nothing should be build during this prebuild phase - scanning of the code and building of the source tarball, for example, take place after this. For custom actions that actually build things, use 'build' instead.

You can use $$name$$ to substitute the path to a referenced srclib - see the srclib directory for details of this.

You can use $$SDK$$, $$NDK$$ and $$MVN3$$ to substitute the paths to the android SDK and NDK directories, and maven 3 executable respectively.

init=xxxx
As for 'prebuild', but runs on the source code BEFORE any other processing takes place.

You can use $$SDK$$, $$NDK$$ and $$MVN3$$ to substitute the paths to the android SDK and NDK directories, and maven 3 executable respectively.

build=xxxx
As for 'prebuild', but runs during the actual build phase (but before the main ant/maven build). Use this only for actions that do actual building. Any prepartion of the source code should be done using 'init' or 'prebuild'.

You can use $$SDK$$, $$NDK$$ and $$MVN3$$ to substitute the paths to the android SDK and NDK directories, and maven 3 executable respectively.

novcheck=yes
Don't check that the version name and code in the resulting apk are correct by looking at the build output - assume the metadata is correct. This takes away a useful level of sanity checking, and should only be used if the values can't be extracted.
fixtrans=yes
Modifies any instances of string resources that use multiple formatting arguments, but don't use positional notation. For example, "Hello %s, %d" becomes "Hello %1$s, %2$d". Newer versions of the Android platform tools enforce this sensible standard. If you get error messages relating to that, you need to enable this.
fixapos=yes
Like fixtrans, but deals with an even older issue relating to 'unescaped apostrophes' in translation strings.
maven=yes
Build with maven instead of ant
patch=x
Apply patch(es). 'x' names one (or more - comma-seperated) files within a directory below the metadata, with the same name as the metadata file but without the extension. Each of these patches is applied to the code in turn.
extlibs=a;b;c
Specifies a list of external libraries (jar files) from the build/extlib library, which will be placed in the libs directory of the project. Separate items with semicolons.
srclibs=a@r;b@r1;
Specifies a list of source libraries (kept up to date using version control) from a predefined set. Separate items with semicolons, and each item is of the form name@rev where name is the predefined source library name and rev is the revision in source control to use. You can then also use $$name$$ in the prebuild command to substitute the relative path to the library directory.

The available source libraries are current hard-coded in common.py. This will later be data-driven.

Another example, using extra parameters:

Build Version:1.09.03,10903,45,subdir=Timeriffic,oldsdkloc=yes