I am building AOSP, v4.4.2. I want to specify a part of the "Build number" string (as per Settings -> About tablet).
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?
The Makefile is what defines how the build number is created (concatenated) for a build.
For user builds (build target, as specified with lunch), the build number will simply be "$(BUILD_ID) $(BUILD_KEYS)
", except if the DISPLAY_BUILD_NUMBER
parameter is set to “true”.
For other builds (i.e. eng/userdebug), much more info is included:
build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS)
The Makefile source is available here: https://android.googlesource.com/platform/build/+/android-4.4.2_r1/core/Makefile#106
As mentioned by @eldarerathis, the BUILD_ID
value in build/core/build_id.mk
is where part of the build string is defined, however this might be overridden in another make (*.mk
) file.
When running lunch
, the value of the BUILD_ID
will be printed for verification. If this value is different to that found in the build_id.mk
file, then search for where it’s being set, and re-configure it. For example, if as part of lunch
, the output includes “4.4.2_1.0.0-ga”:
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.4.2
...
HOST_BUILD_TYPE=release
BUILD_ID=4.4.2_1.0.0-ga
OUT_DIR=out
============================================
...then search for “4.4.2_1.0.0-ga” to find it:
me@mybox:~/AOSP$find . -name "*.mk" | xargs grep "4.4.2_1.0.0-ga"
Then, update the .mk
file that contains the BUILD_ID
. Set other build parameters accordingly.
BUILD_NUMBER
, PLATFORM_VERSION
and BUILD_ID
are located in: build/core/version_defaults.mk
. The values are only set if the build is initiated without them set.
Alternatively (and in my view preferably), these parameters can be set as part of the build command line like this:
me@mybox:~/AOSP$ time m BUILD_ID="MyBuildv1.2" BUILD_NUMBER=12345 2>&1 | tee build.out