Thursday, September 12, 2024

 Building Android 13 AOSP release using source code

Requirements

Host :

500GB of SSD

6+ CPU cores(min) more cores less time for building

16 GB RAM (min)

OS : Ubuntu 64 bit, 18.+, 20.+ and 22.+ release (Note : On Windows Not Possible).

To check the free disk space on terminal :

df -H 

1. Set up your environment :

To prevent errors generated by having the wrong version of Java installed on your computer, we will start by removing any conflicting Java version and adding the correct version. Java 11 is needed to build Android.

sudo apt-get purge openjdk-* icedtea-* icedtea6-*

sudo apt-get update

sudo apt-get upgrade

Install Java JDK 11:

sudo apt-get install openjdk-11-jdk

Check Java Version using this command line.

java -version

The following should be displayed as output:1openjdk 11.0.8 2020-07-14

OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)

OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)

Install build tools

sudo apt-get install bison g++-multilib git gperf libxml2-utils make zlib1g-dev:i386 zip liblz4-tool libncurse

2. Configure Repo and Git :

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/repo

chmod a+x ~/repo

Then run these commands to get git all working:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"

3: Download the source

First, create a folder for your source:

mkdir <Folder_Name>

cd <Folder_Name>

Next follow the below mentioned items you need to follow how to download all of the sources that are required for the branch mentioned after the b tag. Before choosing a particular release for a particular platform code name, version and API level.

Command to checkout the sources:

python3 ~/repo init -u https://android.googlesource.com/platform/manifest -b android-13.0.0_r1

python3 ~/repo sync -j<nproc output>

4: Building

Once you have all of the sources downloaded, you are almost ready to build. Before this however you will need to source the build environment setup script. This will put all of the required build tools and functions into your PATH. You will need to do this every time you get a new terminal session. To be safe, just do it before every build.

source build/envsetup.sh 

You can now use the lunch command (you will need to do this every time you want to build). This will load up a bunch of device profiles. The "lunch" menu combos are made up of two or three fields. The first two show as below explanation

a. The first field (the portion up to the first hyphen '-') is the target hardware (exported as TARGET_PRODUCT).

b. The second field (the portion following the first hyphen, up to the optional second hyphen, or end of line) is one of the keywords, user(Limited access; suited for production) , user-debug(Like user but with root access and debug capability; preferred for debugging), eng(Development configuration with additional debugging tools) release (exported as TARGET_BUILD_VARIANT).

c. The third (optional) field (the portion following the optional second hyphen) is the version (if present, it's exported as

TARGET_PLATFORM_VERSION).

The link here will give more information.

Building Android | Android Open Source Project

lunch

It will display a prompt to choose a combo as below.

You're building on Linux

Lunch menu... pick a combo:

1. aosp_arm-eng

2. aosp_arm64-eng

3. aosp_barbet-userdebug

4. aosp_bluejay-userdebug

5. aosp_bramble-userdebug

6. aosp_bramble_car-userdebug

7. aosp_car_arm-userdebug

8. aosp_car_arm64-userdebug

9. aosp_car_x86-userdebug

10. aosp_car_x86_64-userdebug

11. aosp_cf_arm64_auto-userdebug

12. aosp_cf_arm64_phone-userdebug

13. aosp_cf_x86_64_foldable-userdebug

14. aosp_cf_x86_64_pc-userdebug

15. aosp_cf_x86_64_phone-userdebug

16. aosp_cf_x86_64_tv-userdebug

17. aosp_cf_x86_auto-userdebug

18. aosp_cf_x86_phone-userdebug

19. aosp_cf_x86_tv-userdebug

20. aosp_coral-userdebug

21. aosp_coral_car-userdebug

22. aosp_flame-userdebug

23. aosp_flame_car-userdebug

24. aosp_oriole-userdebug

25. aosp_oriole_car-userdebug

26. aosp_raven-userdebug

27. aosp_raven_car-userdebug28. aosp_redfin-userdebug

29. aosp_redfin_car-userdebug

30. aosp_redfin_vf-userdebug

31. aosp_slider-userdebug

32. aosp_sunfish-userdebug

33. aosp_sunfish_car-userdebug

34. aosp_trout_arm64-userdebug

35. aosp_trout_x86-userdebug

36. aosp_whitefin-userdebug

37. aosp_x86-eng

38. aosp_x86_64-eng

39. arm_krait-eng

40. arm_v7_v8-eng

41. armv8-eng

42. armv8_cortex_a55-eng

43. armv8_kryo385-eng

44. beagle_x15-userdebug

45. beagle_x15_auto-userdebug

46. car_ui_portrait-userdebug

47. car_x86_64-userdebug

48. db845c-userdebug

49. gsi_car_arm64-userdebug

50. gsi_car_x86_64-userdebug

51. hikey-userdebug

52. hikey64_only-userdebug

53. hikey960-userdebug

54. hikey960_tv-userdebug

55. hikey_tv-userdebug

56. poplar-eng

57. poplar-user

58. poplar-userdebug

59. qemu_trusty_arm64-userdebug

60. rb5-userdebug

61. sdk_car_arm-userdebug

62. sdk_car_arm64-userdebug

63. sdk_car_portrait_x86_64-userdebug

64. sdk_car_x86-userdebug

65. sdk_car_x86_64-userdebug

66. sdk_pc_x86_64-userdebug

67. silvermont-eng

68. uml-userdebug

69. yukawa-userdebug

70. yukawa_sei510-userdebugWhich would you like? [aosp_arm-eng]

Select “sdk_phone_x86_64” by running commands.

sdk_phone_x86_64

or you can simply type:

lunch sdk_phone_x86_64

After selecting the combo the following output is shown on screen. Go through it and confirm that this is the target and device you require

the build.

Result on terminal for choosing “sdk_phone_x86_64”:

============================================

PLATFORM_VERSION_CODENAME=REL

PLATFORM_VERSION=13

TARGET_PRODUCT=sdk_phone_x86_64

TARGET_BUILD_VARIANT=eng

TARGET_BUILD_TYPE=release

TARGET_ARCH=x86_64

TARGET_ARCH_VARIANT=x86_64

TARGET_2ND_ARCH=x86

TARGET_2ND_ARCH_VARIANT=x86_64

HOST_ARCH=x86_64

HOST_2ND_ARCH=x86

HOST_OS=linux

HOST_OS_EXTRA=Linux-5.15.0-52-generic-x86_64-Ubuntu-22.04.1-LTS

HOST_CROSS_OS=windows

HOST_CROSS_ARCH=x86

HOST_CROSS_2ND_ARCH=x86_64

HOST_BUILD_TYPE=release

BUILD_ID=TP1A.221005.002

OUT_DIR=out

PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl hardware/google/camera

hardware/google/camera/devices/EmulatedCamera device/generic/goldfish device/generic/goldfish-opengl

============================================

make -j<70%nproc> 2>&1 | tee aosp_build_log.txt

You should avoid using the same file name in case if the build results in error and after fixing the errors, when you want to build again, use a different file name each time to save the history of failure to success for each iteration of build, error and fix activity.

The final output generally says something like “Build completed successfully”. If you look just above this, a green line will appear before this

final line with the same output. Otherwise, if you don't see this, then there might be some issues and check the final log to find the clue.

Finally run the emulator

emulator

No comments:

Post a Comment

 Building Android 13 AOSP release using source code Requirements Host : 500GB of SSD 6+ CPU cores(min) more cores less time for building 16 ...