Ubuntu20.04下编译Android系统源码
宿主系统:Ubuntu 20.04
源码版本:Android8最新版 android-8.1.0_r81
1.工具安装:git、curl及编译工具
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
2.git用户设置
git config --global user.name xxxgit config --global user.email xxx@qq.com
3.下载repo工具
git clone https://aosp.tuna.tsinghua.edu.cn/git-repo/chmod a+x git-repo/repoexport PATH=~/git-repo:$PATH // 每次打开终端需要设置
修改repo文件中的 REPO_URL = 'https://mirrors.tuna.tsinghua.edu.cn/git/git-repo’
4.同步manifest查看branches
创建文件夹存放源码:mkdir AndroidSource
移动到该目录:cd AndroidSource
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
查看所有分支版本:cd .repo/manifests.git/git branch -a
5.同步分支
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-8.1.0_r81repo sync -c -j8 # j8表示8个线程进行下载
6.安装jdk
sudo apt-get install openjdk-8-jdksudo apt-get install openjdk-8-jre
7.编译前设置
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
Jack Server安装问题:提示Jack server installation not foundcd prebuilts/sdk/tools/./jack-admin install-server jack-launcher.jar jack-server-4.11.ALPHA.jar
// ls查看版本,不一定是4.11。
安装完成后,会在用户目录生成文件夹 .jack-server 和文件 .jack-settings
####################
8.选择target、准备编译环境
Select device target
lunch aosp_arm64-eng
Build sources (cofee time)
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
10.运行模拟器
编译完成后可直接运行:emulator
之后运行时需要重新设置环境:source build/envsetup.shlunch aosp_arm64-eng #选择刚才你设置的目标版本emulator
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)