ubuntu16.4编译andorid10全纪录.md
注意事项:
如果是登陆过google账号的pixel一定要退出,否则刷机之后上来有个联网验证,还跳过不了,必须用能FQ的wifi才行。
修改源
更改为国内的源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vi /etc/apt/sources.list
内容如下
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
更新源
sudo apt-get update
sudo apt-get upgrade
安装编译依赖项
sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig libncurses5
安装openjdk8,官方说明安卓10需要用open jdk8。
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
下载repo工具
mkdir ~/bin
PATH=~/bin:$PATH
curl https://aosp.tuna.tsinghua.edu.cn/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
git配置
mkdir androidSource (名称随意,我这里叫Aosp)
cd androidSource
git config --global user.name "cxapython"
git config --global user.email "1598828268@qq.com"
安装Python3.8
安装所需依赖
apt install -y --force-yes gconf-service libasound2 rsync libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils
开始下载并安装python3.8
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz
tar Jxf Python-3.8.0.tar.xz
cd Python-3.8.0
./configure prefix=/usr/local/python3
make
sudo make install
链接一下
sudo rm /usr/bin/python
sudo rm /usr/bin/python3
sudo ln -s /usr/local/python3/bin/python3.8 /usr/bin/python
sudo ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
然后将python2的也链接一下,如果已经安装了就不用下载了,直接链接即可。后面编译会用到
sudo apt install python2
sudo ln -s /usr/bin/python2.7 /usr/bin/python2
下载初始包
工具下载:https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar,我当时直接火狐浏览器下载的。
下载好的初始包(100G左右),在home目录建个源码目录,用普通用户,不要用root
cd ~
mkdir androidSource
然后把下载好的aosp-latest.tar复制到androidSource目录,进行解压,记得用普通用户,编译源码的时候如果用root用户会报错,所以要用普通用户解压,要不然回头还得改文件的所有者,解压完删除aosp-latest.tar
tar xvf aosp-latest.tar
rm aosp-latest.tar
首先,确认哪个版本的Android10可以刷到PIXEL手机上。在这里确认下https://source.android.google.cn/docs/setup/about/build-numbers?hl=zh-cn
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-10.0.0_r17
如果您想编译镜像给手机google原生手机用,那么久需要谨慎一点。因为这里有个规则。因为手机涉及到真是的驱动程序,需要先确定某个手机的驱动版本和android系统版本是否匹配。
先去查看系统与系统列表
查看android10.0.0_r17对应的版本号QP1A.191005.007.A3。
接下来就是同步代码咯
repo sync -j4
Checking out: 100% (733/733), done in 13m51.539s
repo sync has finished successfully.
驱动解压缩
因为我们是要往真实手机Pixel上安装的。
将两个脚本copy到源码所在目录/androidSource/aosp
,并分别执行。得到vendor目录
在执行sh脚本的时候,一定要注意其过程中还要手动输入“I ACCEPT”
开始编译
//1. 建立android-q开发分支:
repo start android_q --all
source build/envsetup.sh
lunch
选择 sailfish 我这里是16.
- aosp_sailfish-userdebug
make -j4
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=10
TARGET_PRODUCT=aosp_sailfish
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=kryo
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=kryo
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.15.0-142-generic-x86_64-Ubuntu-16.04.6-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=QP1A.191005.007.A3
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/google/marlin vendor/google/camera hardware/google/pixel
============================================
[ 99% 134/135] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja
之后开始编译 大概等了6个小时吧,挂机一晚上差不多。
最后成功的话可以看到如下信息。
[100% 92033/92033] Install system fs image: out/target/product/sailfish/system.img
#### build completed successfully (06:56:53 (hh:mm:ss)) ####
在编译之后的输入镜像文件,其所在路径为"/out/target/product/sailfish"目录里面,后面就可以开始刷机了。
刷机
先下载官网的底包。
千万不要下错手机型号,因为其他型号也有QP1A.191005.007.A1
然后解压下载的压缩包,替换image-...zip里面的截图中的三个文件即可,别忘了再压缩回去。
此时手机重启到bootloader,执行flash-all.sh即可
adb reboot bootloader
./flash-all.sh
如果不行,可以先刷一下下载的官方包,然后再刷你修改后的包
参考链接
https://blog.csdn.net/dirksmaller/article/details/112761115
https://blog.csdn.net/mingmigndfds/article/details/113884464