How to download and build Android 13, AOSP

Recently, Android 13 has been added to the Android Open Source Project (AOSP).

AOSP consists of many git projects, and the repo tool makes it easy to download many git projects.

First, I will introduce how to install the repo tool and download the AOSP codes through repo.

1. Install REPO

Repo is a tool implemented as a script. All you have to do is download it. First, create a ~/bin folder and register it in the PATH.

$ mkdir ~/bin
$ PATH=~/bin:$PATH

Download the repo tool using the curl command to the ~/bin folder. And give execution permission to the repo.

$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

2. Download Android 13 sources

Before using Repo to get the Android open source, create a folder first. Create it in an appropriate place and move into the folder you created.

$ mkdir android13
$ cd android13

And because Repo uses git, you must install git. Once you have installed git, you must register your basic settings, such as your user name and user email. Please enter your name and email.

$ git config --global user.name "Your Name"
$ git config --global user.email "you@example.com"

Now we are ready to download the AOSP source with the Repo tool.

2.1 Download Android 13 branch

The following command sets up a project for the source of Android 13's android-13.0.0_r11 branch.

$ repo init -u https://android.googlesource.com/platform/manifest -b android-13.0.0_r11

All branch information of AOSP can be found in Source Code Tags and Builds. If there is a newer branch than android-13.0.0_r11, you can download it.

When you execute the command, if you see the message repo has been initialized, it means the setup is complete.

$ repo init -u https://android.googlesource.com/platform/manifest -b android-13.0.0_r11
Downloading Repo source from https://gerrit.googlesource.com/git-repo

... A new version of repo (2.29) is available.
... You should upgrade soon:
    cp /home/js/test/android13/.repo/repo/repo /home/js/.bin/repo


Your identity is: farfs <farfs.dev@gmail.com>
If you want to change this, please re-run 'repo init' with --config-name

repo has been initialized in /home/js/test/android13

And, when the repo sync command is entered, the git projects set up during setup will be downloaded.

$ repo sync

Receiving objects: 100% (6238/6238), 5.32 MiB | 25.67 MiB/s, done.
Resolving deltas: 100% (1584/1584), done.
Receiving objects: 100% (13918/13918), 7.89 MiB | 37.74 MiB/s, done.
Resolving deltas: 100% (4645/4645), done.
Receiving objects: 100% (1493/1493), 1.10 MiB | 43.47 MiB/s, done.
.....

2.2 Make sure Android 13 downloaded

Once repo sync is complete, you can check the downloaded files as follows.

$ ls
Android.bp  bionic    bootstrap.bash  compatibility  dalvik      development  docs      frameworks  kernel   libnativehelper  packages  platform_testing  sdk     test       tools
art         bootable  build           cts            developers  device       external  hardware    libcore  Makefile         pdk       prebuilts         system  toolchain

3. Build Android 13

First, set up the build-related dependencies in the downloaded project with the following command.

$ source build/envsetup.sh

And then, select the type of device or architecture to build with the following command.

$ lunch
You\'re building on Linux
Lunch menu... pick a combo:
     1. aosp_arm-eng
     2. aosp_arm64-eng
     3. aosp_mips-eng
     4. aosp_mips64-eng
     5. aosp_x86-eng
     6. aosp_x86_64-eng
....

Which would you like? [aosp_arm-eng] 6

Once you have finished setting up the device and architecture, you can build the entire project with the following command. The -jN option sets the number of threads to use when building to N. -j8 builds with 8 threads.

$ m -j8

4. Run Android 13 on Emulator

Once the build is complete, Android images will be generated.

Enter the following command to run the compiled Android image on the emulator.

$ emulator

Related Posts

codechachaCopyright ©2019 codechacha