宿主系统:Ubuntu 20.04
源码版本:Android8最新版 android-8.1.0_r81
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
git config --global user.name xxx
git config --global user.email [email protected]
git clone https://aosp.tuna.tsinghua.edu.cn/git-repo/
chmod a+x git-repo/repo
export PATH=~/git-repo:$PATH // 每次打开终端需要设置
修改repo文件中的 REPO_URL = 'https://mirrors.tuna.tsinghua.edu.cn/git/git-repo’
创建文件夹存放源码:
mkdir AndroidSource
移动到该目录:
cd AndroidSource
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
查看所有分支版本:
cd .repo/manifests.git/
git branch -a
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-8.1.0_r81
repo sync -c -j8 # j8表示8个线程进行下载
sudo apt-get install openjdk-8-jdk
sudo apt-get install openjdk-8-jre
prebuilts/misc/linux-x86/ccache/ccache -M 50G
make clobber
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
source build/envsetup.sh
Jack Server安装问题:提示Jack server installation not found
cd prebuilts/sdk/tools/
./jack-admin install-server jack-launcher.jar jack-server-4.11.ALPHA.jar
// ls查看版本,不一定是4.11。
安装完成后,会在用户目录生成文件夹 .jack-server 和文件 .jack-settings
####################
lunch aosp_arm64-eng
make -j8
1.Assertion cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
在Ubuntu18上使用交叉编译工具,报这个错。研究之下发现,工具的绝对路径过长,ubuntu18对其优化,修改路径,导致报错。
sol:使用命令:export LC_ALL=C
编译完成后可直接运行:
emulator
之后运行时需要重新设置环境:
source build/envsetup.sh
lunch aosp_arm64-eng #选择刚才你设置的目标版本
emulator