编译Android 8.0系统 并刷入pixel

前言:

这学期的项目需要对android系统中art以及framework进行一些简单的修改。万事开头难,先从编译源码并刷入机器开始。

部分环境:

手机:Pixel
系统:Ubuntu 18.04.2 LTS
处理器:Intel® Core™ i7-7700HQ CPU @ 2.80GHz
虚拟机:VMware® Workstation 15 Pro
虚拟机内存: 8GB
虚拟机硬盘: 300GB

官方教程:

https://source.android.com/setup/build/requirements

下载:

建bin来存放repo,并配置repo的环境变量

mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

配置git的用户信息

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

进行初始化

repo init -u https://android.googlesource.com/platform/manifest

特定版本的代码:

repo init -u https://android.googlesource.com/platform/manifest -b android-8.0.0_r2

ps: 直接从谷歌下载可能会遇到问题,推荐使用科大源
修改repo文件中 REPO_UPRL

REPO_URL = 'https://gerrit-googlesource.lug.ustc.edu.cn/git-repo'

并且init时候采用下面指令

repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-8.0.0_r2

最后

repo sync

即可下载源代码。

编译

由于部分硬件驱动是非开源的,因此要刷到pixel上面,首先要下载相应的固件(注意对应号系统型号)
下载地址:
https://developers.google.com/android/drivers#sailfishopr6.170623.011
之后选择对应版本,这里针对pixel选择aosp_sailfish-userdebug

解压之后放到源代码的根目录下执行这两个文件

./extract-google_devices-sailfish.sh
./extract-qcom-sailfish.sh

然后就进行编译即可,注意需要lunch的版本根据机器不同有所区别

. build/envsetup.sh
lunch aosp_sailfish-userdebug
make -j8

编译时候遇到的坑及解决方案

编译时候会遇到很多坑,这里列举几个我碰到的(依赖相关的没有放上来)
1

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

2

Out of memory error (version 1.3-rc6 'Douarn' (441800 22a11d4b264ae70e366aed3025ef47362d1522bb by android-jack-team@google.com)).

解决方案

export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"
out/host/linux-x86/bin/jack-admin kill-server
out/host/linux-x86/bin/jack-admin start-server

刷机

官方教程:
https://source.android.com/setup/build/running.html#flashing-a-device
进去fastboot模式(如果不成功可以加sudo试试)

fastboot devices
fastboot -w flashall

至此刷机成功,接下来的工作就是对系统进行一些修改并刷入设备了

posted @ 2019-04-08 18:55  zhangxianlong  阅读(1048)  评论(0编辑  收藏  举报