Details of the Issue with Building AOSP 14
Problem Description
When attempting to build AOSP 14, I encountered an error during the build process. The build environment was configured according to the requirements for AOSP 14, but I encountered the following error:
internal error: undefined variable CTS_TEST_SUITES_DEFAULT
11:02:32 fatal errors encountered
#### failed to build some targets (02:25 (mm:ss)) ####
Steps Taken
-
Environment Setup:
- Executed
source build/envsetup.sh
. - Selected the build environment with the command
lunch aosp_cf_x86_64_phone-trunk_staging-userdebug
.
- Executed
-
Build Information:
PLATFORM_VERSION_CODENAME=VanillaIceCream
TARGET_PRODUCT=aosp_cf_x86_64_phone
TARGET_BUILD_VARIANT=userdebug
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.4.0-150-generic-x86_64-Ubuntu-18.04.6-LTS
BUILD_ID=MAIN
-
Memory Warning:
- My machine has 16 GB of RAM.
Errors Encountered
- Error:
internal error: undefined variable CTS_TEST_SUITES_DEFAULT
- Details: Build failed due to fatal errors.
Full Terminal
thanhchung@Chung-Computer:/media/thanhchung/data/AOSP14$ source build/envsetup.sh
thanhchung@Chung-Computer:/media/thanhchung/data/AOSP14$ lunch aosp_cf_x86_64_phone-trunk_staging-userdebug
============================================
PLATFORM_VERSION_CODENAME=VanillaIceCream
PLATFORM_VERSION=VanillaIceCream
TARGET_PRODUCT=aosp_cf_x86_64_phone
TARGET_BUILD_VARIANT=userdebug
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=silvermont
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=silvermont
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.4.0-150-generic-x86_64-Ubuntu-18.04.6-LTS
HOST_CROSS_OS=windows
BUILD_ID=MAIN
OUT_DIR=out
============================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wondering whether to use user, userdebug or eng?
user The builds that ship to users. Reduced debugability.
userdebug High fidelity to user builds but with some debugging options
enabled. Best suited for performance testing or day-to-day use
with debugging enabled.
eng More debugging options enabled and faster build times, but
runtime performance tradeoffs. Best suited for day-to-day
local development when not doing performance testing.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
thanhchung@Chung-Computer:/media/thanhchung/data/AOSP14$ echo "$TARGET_PRODUCT-$TARGET_RELEASE-$TARGET_BUILD_VARIANT"
aosp_cf_x86_64_phone-trunk_staging-userdebug
thanhchung@Chung-Computer:/media/thanhchung/data/AOSP14$ m
11:00:10 ************************************************************
11:00:10 You are building on a machine with 15.6GB of RAM
11:00:10
11:00:10 The minimum required amount of free memory is around 16GB,
11:00:10 and even with that, some configurations may not work.
11:00:10
11:00:10 If you run into segfaults or other errors, try reducing your
11:00:10 -j value.
11:00:10 ************************************************************
============================================
PLATFORM_VERSION_CODENAME=VanillaIceCream
PLATFORM_VERSION=VanillaIceCream
TARGET_PRODUCT=aosp_cf_x86_64_phone
TARGET_BUILD_VARIANT=userdebug
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=silvermont
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=silvermont
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.4.0-150-generic-x86_64-Ubuntu-18.04.6-LTS
HOST_CROSS_OS=windows
BUILD_ID=MAIN
OUT_DIR=out
============================================
internal error: undefined variable CTS_TEST_SUITES_DEFAULT
11:02:32 fatal errors encountered
#### failed to build some targets (02:25 (mm:ss)) ####
thanhchung@Chung-Computer:/media/thanhchung/data/AOSP14$
2
Answers
Solution for AOSP 14 Build Error
I found the solution. The error occurred due to insufficient memory (16GB of RAM isn't enough). To fix this, you need to create a swapfile on your SSD.
Here’s how to create a 34GB swapfile:
Check Available Disk Space:
Create a 34GB Swapfile:
If
fallocate
is unavailable:Set Permissions:
Format as Swap:
Activate the Swapfile:
Verify:
Make It Permanent:
Additional Advice
After setting up the swapfile, it's recommended to
repo init
,repo sync -j$(nproc)
The error looks explicit – you need at least 64GB of RAM to build AOSP AOSP Build Requirements