B01c: Setup AOSP Build Environment

B01c: Setup AOSP Build Environment

Info

You will have to re-run the following command each time you leave your build environment, e.g. by closing/changing your shell or restarting your system.

Ensure you are in the ~/android directory, then run the following commands:

source build/envsetup.sh

# Always run *lunch* afterwards! See next step!

In case you encounter the following error, please ignore it:

Build sandboxing disabled due to nsjail error.

Try out Repo Commands

The AOSP source tree is managed by a python tool called repo that utilizes git to manage and download a huge number of git repositories. repo also helps to automate parts of the development workflow.

Repo has several sub commands. Here's a selection of commands to try. You can look up their description using repo help:

cd android

repo status

repo diff

repo forall -c git remote -v

repo help

Warning

If you use the cloud instances, repo might notify you about a newer version being available upstream. Please do not upgrade because this training has only been tested with the currently installed version.

Choose the Target Device

To list all build targets (aka. lunch targets) you can execute

lunch

Since Android 14 this will print an empty list by default because some internal cache has not been generated yet. Please execute

# Available releases are: ap2a next staging trunk trunk_food trunk_staging.
export TARGET_RELEASE=trunk_staging
build_build_var_cache

And then lunch again. Now you should see a very long list of targets.

To select a lunch target at once, without selecting it by typing the number on the console, execute

lunch aosp_cf_x86_64_auto-trunk_staging-userdebug

Here we use the lunch target aosp_cf_x86_64_auto-trunk_staging-userdebug. cf_x86_64_auto is the AAOS Virtualization reference design based on cuttlefish.

userdebug is the build variant. See the documenation Choose a target for more information about it.