Building Android 11
This article introduces how to compile the Android system, including compilation and packaging of U-Boot, kernel, and AOSP.
Environment Setup
System Requirements
apt-get update -y && apt-get install -y openjdk-8-jdk python git-core gnupg flex bison gperf build-essential \
zip curl liblz4-tool zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
libgl1-mesa-dev libxml2-utils xsltproc unzip mtools u-boot-tools \
htop iotop sysstat iftop pigz bc device-tree-compiler lunzip \
dosfstools vim-common parted udev libssl-dev python3 python-pip lzop swig
Downloading Repo
Repo is a tool used in Android development for managing multiple Git repositories. It's a Python script that helps developers with version control and management of multiple Git repositories. You can download Repo using the following commands:
wget https://storage.googleapis.com/git-repo-downloads/repo -P ~/bin/
or
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
Downloading Source Code
$ repo init -u https://github.com/radxa/manifests.git -b Android11_Radxa_rk11 -m rockchip-r-release.xml $ repo sync -d --no-tags -j4
Building the Image
There are two methods to build the image:
Method 1 (Recommended)
Using the SDK build script for compilation:
$ source build/envsetup.sh $ lunch rk3399_ROCKPI4B_Android11-userdebug $ ./build.sh -UACKu
After the compilation is complete, you can find the image in the IMAGE directory.
Method 2
You can follow these steps to build the image:
- Set up the build environment
$ source build/envsetup.sh $ lunch rk3399_ROCKPI4B_Android11-userdebug
- Compile U-Boot
$ ./build.sh -U
- Compile the kernel
$ ./build.sh -CK
- Compile AOSP
$ ./build.sh -A
- Generate Images
$ ./build.sh -u
Common Issues
- For Android 11, it's recommended to compile in an Ubuntu 16.04 environment as other Ubuntu versions may cause compilation errors.