1.代码下载
1. 下载repo工具
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
2. 修改~/.bashrc,在文件最后添加
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
3. 选择ROM分支
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-7.1.2_r27 --depth=1 --platform=auto
4. 同步ROM源码
repo sync -c --no-tags --no-clone-bundle -j$(nproc --all)
注:ROM版本选择,ROM分支列表
2. 编译环境配置
sudo apt-get 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 ccache libgl1-mesa-dev libxml2-utils xsltproc unzip libncurses5 openjdk-8-jdk
3.编译问题汇总
编译错误一:
FAILED: /bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -oout/target/product/bullhead/obj/STATIC_LIBRARIES/libedify_intermediates/lexer.cpp bootable/recovery/edify/lexer.ll" flex-2.5.39: loadlocale.c:130:_nl_intern_locale_data: ?? 'cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' ??? Aborted (core dumped)
解决方案:编译之前,执行:
export LC_ALL=C
编译错误二:
Ensuring Jack server is installed and started
FAILED: setup-jack-server
/bin/bash -c "(prebuilts/sdk/tools/jack-admin install-server prebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.11.ALPHA.jar 2>&1 || (exit 0) ) && (JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation"
prebuilts/sdk/tools/jack-admin start-server 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update server prebuilts/sdk/tools/jack-server-4.11.ALPHA.jar 4.11.ALPHA 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-4.32.CANDIDATE.jar 4.32.CANDIDATE || exit 47 )"
Jack server already installed in "/home/user/.jack-server"
Communication error with Jack server (35), try 'jack-diagnose' or see Jack server log
SSL error when connecting to the Jack server. Try 'jack-diagnose'
SSL error when connecting to the Jack server. Try 'jack-diagnose'
ninja: build stopped: subcommand failed.
22:32:18 ninja failed with: exit status 1
解决方法:检查jdk中关于java.security的配置,编译用到的是openjdk-8-jdk,其版本是1.8.0_362-8u362, 默认禁用了TLSv1、TLSv1.1。需要调整下,在/etc/java-8-openjdk/security/java.security中取消TLSv1, TLSv1.1 禁用, 然后执行:
./prebuilts/sdk/tools/jack-admin kill-server
./prebuilts/sdk/tools/jack-admin start-server
4. 编译内核
下载内核文件,以goldfish为例
git clone https://aosp.tuna.tsinghua.edu.cn/kernel/goldfish.git
当然也可以选择其他版本
git clone https://aosp.tuna.tsinghua.edu.cn/kernel/common.git
git clone https://aosp.tuna.tsinghua.edu.cn/kernel/exynos.git
git clone https://aosp.tuna.tsinghua.edu.cn/kernel/hikey-linaro.git
git clone https://aosp.tuna.tsinghua.edu.cn/kernel/lk.git
git clone https://aosp.tuna.tsinghua.edu.cn/kernel/msm.git
git clone https://aosp.tuna.tsinghua.edu.cn/kernel/omap.git
git clone https://aosp.tuna.tsinghua.edu.cn/kernel/samsung.git
git clone https://aosp.tuna.tsinghua.edu.cn/kernel/tegra.git
git clone https://aosp.tuna.tsinghua.edu.cn/kernel/x86_64.git