AOSP Build and Development helper Guide with various commands available

This article will cover many commands that can be used while building and developing the AOSP customization.

Narendra Harny
5 min readJan 22, 2025
Photo by Ionela Mat on Unsplash

List of Commands and Functions Available

addcompletions
add_lunch_combo
allmod
avbtool
banchan
bmod
build_build_var_cache
cgrep
check_product
check_type
check_variant
choosecombo
chooseproduct
choosetype
choosevariant
_complete_android_module_names
core
coredump_enable
coredump_setup
cproj
_croot
croot
destroy_build_var_cache
dirmods
enable_zsh_completion
get_abs_build_var
getbugreports
get_build_var
getlastscreenshot
get_make_command
getprebuilt
getscreenshotpath
getsdcardpath
gettargetarch
_gettop_once
ggrep
godir
gogrep
gomod
hmm
installmod
is
isviewserverstarted
jgrep
jsongrep
key_back
key_home
key_menu
ktgrep
_lunch
lunch
m
make
mangrep
mgrep
mm
mma
mmm
mmma
multitree_build
multitree_gettop
multitree_lunch
_multitree_lunch_error
multitree_lunch_help
outmod
owngrep
pathmod
pez
printconfig
print_lunch_menu
provision
pygrep
qpid
rcgrep

add_lunch_combo

add_lunch_combo aosp_arm-eng

Use add_lunch_combo when setting up your environment to build a specific target device or configuration. This command is typically used after initializing your environment with the source build/envsetup.sh script.

It is useful when selecting different build targets like user-debug, user, or eng based on the type of build you’re preparing for.

bmod

The bmod command is used in the context of Android's build environment to manage and build individual modules or parts of the Android source code. It focuses on building specific modules within the system rather than building the entire AOSP tree.

bmod <module_name>
bmod frameworks/base

Use bmod when you want to build or rebuild a specific module without rebuilding the entire AOSP tree.

It’s useful in a large Android project where you only want to focus on certain components (e.g., a specific feature or subsystem) and avoid waiting for the entire system to build.

cgrep

The cgrep command is a search utility used to search through the Android source code for specific patterns or strings, similar to grep. However, it’s optimized for the Android build environment.

cgrep sensor

Use cgrep to search for specific keywords, functions, or references within the source code of an Android project.

It’s useful for quickly finding relevant code snippets, definitions, or function calls when working on specific features or debugging.

This command is typically used in the Android source tree to filter through large amounts of code.

ggrep

The ggrep command is used to search for a specific pattern in the entire Android source tree. It is essentially a wrapper for the grep command, designed to make it easier to search across large codebases like AOSP.

ggrep 'target_*'

ggrep is a faster and more efficient search tool tailored for AOSP, as it is optimized to search within the vast number of files in the Android source tree.

gogrep

The gogrep command is used to search for a pattern or string within a specific directory or module in the Android source tree, much like ggrep, but it is generally used for searching within a smaller scope, such as a specific module or component.

gogrep setUp() frameworks/

Use this command when you want to perform a search within a specific directory or module, rather than the entire source tree.
It’s particularly useful when working with a smaller subset of the Android source tree and you want to focus your search on a particular section of the codebase.

jgrep

The jgrep command is used to search for Java-related code or strings in the Android source code. It is specifically designed to search within Java files, making it useful for debugging or inspecting Java-related parts of the Android codebase.

jgrep <search_pattern>

Similarly!!!!!!
jsongrep → JSON File

ktgrep → Kotlin Files

mangrep → Manifest Files

mgrep → Make Files

pygrep → Python Files

rcgrep → RC files

resgrep → Resource Files

key_back

The key_back command simulates pressing the Back button on an Android device. This can be useful for testing or automation purposes when you need to programmatically trigger the back action without physically pressing the device’s back button.

Similarly!!!!!!!

key_home → Launches Home

key_menu → For Menu

choosecombo

The “choosecombo” command is used to select a target product, variant, and build type (e.g., user, user debug, or eng) for the Android build process. It’s an interactive tool that allows you to choose which configuration to build.

choosecombo
Build type choices are:
1. release
2. debug

Which would you like? [1] 2


Which product would you like? [sdk_car_x86_64]

Use “choosecombo” when you need an easy way to select a configuration for your build environment. It simplifies the process of configuring the build for a specific product and build type without manually typing commands.

chooseproduct

After running this command, it will prompt you with a list of available products, such as.

After running this command, it will prompt you with a list of available products, such as:

It is the same as lunch whereas with chooseproduct, you would run the command and then select from the list of available options interactively.

croot

Use croot when you are deep within the Android source tree and want to quickly navigate back to the root directory. It saves time by automatically setting the directory to the root of the AOSP (Android Open Source Project).

destroy_build_var_cache

Use this command when you have modified build configurations or variables (such as in Android.mk, Boardconfig.mk, or other configuration files) and want to ensure that the system reflects the changes in the next build.
It’s helpful when you encounter issues where changes in the build environment don’t seem to be applied, as it ensures the cache is refreshed.

dirmods

Use dirmods when you want to verify the changes you’ve made in a particular directory of the Android source tree before staging, committing, or building.
It helps to identify untracked or modified files and confirm your changes are as expected.

get_build_var

The get_build_var command retrieves the value of a specified build variable from the Android build environment. It is used to query variables that are defined during the build configuration process.

get_build_var TARGET_PRODUCT
get_build_var TARGET_ARCH

installmod

The installmod command is used to install a module into the Android build system. It typically installs a module or component that is required for the build, which might include prebuilt modules or other dependencies.

installmod <module_name>

printconfig

The printconfig command is used to print the current configuration of the AOSP build environment. It shows various build variables, options, and settings that are active for the current build session.

print_lunch_menu

The print_lunch_menu command is used to display a list of available lunch configurations for the AOSP build system. It shows all the possible targets that you can build, including devices, product configurations, and build types.

I left a few commands on the like mm because they are generally used by everyone.

Thanks for Reading!

Please comment with questions and suggestions!! If this blog is helpful for you then hit Please hit the clap! Follow on Medium, Connect on LinkedIn, Follow on Insta and send emails if any discussion is needed on the same topic on copy email.

Thank you!

--

--

Narendra Harny
Narendra Harny

Written by Narendra Harny

Connect on https://medium.com/make-android | Write On, Android AOSP & Applications | Python | DevOps | Java | C++ | Kotlin | Shell | Linux | Android Auto | IVI

No responses yet