How can the AOSP build number be customized?

CJBS picture CJBS · Jan 27, 2015 · Viewed 8.1k times · Source

I am building AOSP, v4.4.2. I want to specify a part of the "Build number" string (as per Settings -> About tablet).

About tablet page

I know that this can be done for the Kernel by using the CONFIG_LOCALVERSION defconfig value. But I want to change "Build number", not "Kernel version" (which I was able to do successfully).

Currently, the pertinent parts of my AOSP build are like this:

# Source build variables
. build/envsetup.sh

# Specify the build target:
# * user -> limited access; suited for production (no ADB)
# * userdebug -> like "user" but with root access and debuggability; preferred for debugging
# * eng -> development configuration with additional debugging tools (with ADB)
lunch mydevice-eng

# Build it!
time m 2>&1 | tee build.out

What should I change to specify the build number?

Answer

eldarerathis picture eldarerathis · Jan 27, 2015

The BUILD_ID value in build/core/build_id.mk is where this is defined:

# BUILD_ID is usually used to specify the branch name
# (like "MAIN") or a branch name and a release candidate
# (like "CRB01").  It must be a single word, and is
# capitalized by convention.

export BUILD_ID=KOT49H

That value gets written to your build's properties, and Settings reads it from there, so you simply need to change that one export to whatever you want. The comment is merely informational, you need not follow the conventions outlined there. In the master branch they have it defined as AOSP currently.

Another available flag is DISPLAY_BUILD_NUMBER (example). It's optional, and probably not needed in your situation, but here is a description of how it works, in case it might be of use:

# DISPLAY_BUILD_NUMBER should only be set for development branches,
# If set, the BUILD_NUMBER (cl) is appended to the BUILD_ID for
# a more descriptive BUILD_ID_DISPLAY, otherwise BUILD_ID_DISPLAY
# is the same as BUILD_ID
DISPLAY_BUILD_NUMBER := true