Ubuntu 20.04编译Android 8.1


一、配置环境

sudo apt install git-core gnupg flex bison gperf build-essential \
      zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
      lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev \
      libncurses5 libxml2-utils python xsltproc unzip

二、配置环境变量.bash_profile

# Compiler cache
export USE_CCACHE=1
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
export PATH=~/Documents/android/bin:$PATH
export ANDROID_JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
export PATH=$ANDROID_JAVA_HOME/bin:$PATH
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'

四、下载AOSP源代码
? 下载repo并设置权限

mkdir ~/Documents/android/bin
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/Documents/android/bin/repo
chmod a+x ~/Documents/android/bin/repo

? 初始化仓库

cd ~/Documents/android_8.1
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-8.1.0_r62
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-8.1.0_r62
repo sync -c

五、编译AOSP源代码

cd ~/Documents/android_8.1
# Set ccache
prebuilts/misc/linux-x86/ccache/ccache -M 50G 
# Clean out directory
make clobber 
# Jack server configuration
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx6g"
./prebuilts/sdk/tools/jack-admin kill-server
./prebuilts/sdk/tools/jack-admin start-server 
# Setup environment 
source build/envsetup.sh

# Select device target
lunch
# Build sources (cofee time)
make -j8

六、编译单项

source build/envsetup.sh
cd external/tinyxml
mm