Compiling Android 14 source code for Raspberry Pi 5
1. Hardware and software requirements
Official recommended configuration:
- Ubuntu 22.04 Virtual Machine
- Memory is 16GB minimum
- The minimum disk size is 360 GB
2. Install dependent tools
Official document: https://source.android.google.cn/docs/setup/start/initializing?hl=zh-cn.
sudo apt install git-core gnupg flex bison build-essential zip curl zlib1g-dev libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
sudo apt install curl git python3 python3-pip pkg-config cmake
sudo apt install libssl-dev python3-setuptools repo
The default python for ubutun is python2, which is no longer officially supported in the future, so it needs to be replaced.
sudo ln -s /usr/bin/python3 /usr/bin/python
Install meson, do not use sudo apt install meson
installation, so that the installed meson version is too low to compile.
pip3 install --user meson
pip3 install --user mako
sudo mv ~/.local/bin/meson /usr/bin/
sudo mv ~/.local/bin/mako-render /usr/bin/
Restart the terminal.
Check meson:
meson -v
Download latest version of ninja from https://github.com/ninja-build/ninja/releases
sudo unzip ninja-linux.zip -d /usr/local/bin
sudo update-alternatives --install /usr/bin/ninja ninja /usr/local/bin/ninja 1 --force
3. Pre-configuration
- Configure git
git config --global user.name 'xxx'
git config --global user.email 'xxx@xx.com'
- The repo configuration
mkdir ~/bin
PATH=~/bin:$PATH
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod +x ~/bin/repo
- Replace Tsinghua yuan
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
4. Download the Android 14 source code
- Initialize the warehouse and specify the version
mkdir -p ~/workspace/android-src_14.0.0_r21
cd ~/workspace/android-src_14.0.0_r21
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-14.0.0_r21
git clone https://gitee.com/android-rpi-mirror/local_manifests_mirror .repo/local_manifests -b arpi-14
# Or use
# git clone https://github.com/android-rpi/local_manifests .repo/local_manifests -b arpi-14
- Pull source code
repo sync -c -j8
5. Extend the swap partition
A swap partition that is too small causes compilation to fail without error:
[100% 1/1] analyzing Android.bp files and generating ninja file at out/soong/build.ninja
FAILED: out/soong/build.ninja
cd "(dirname "out/host/linux-x86/bin/soong_build")" && BUILDER="PWD/$(basename "out/host/linux-x86/bin/soong_build")