Android 12 源码下载、编译与烧录到Pixel 3a
android 12 源码下载、编译与烧录到Pixel 3a
- 当前设备环境
- 源码下载
- 温馨跳转
- 个人总结源码下载
- 谷歌手机设备驱动的下载
- 编译
- 烧录
当前设备环境
操作系统:ubuntu 18.04 LTS
手机:谷歌手机Pixel 3a
下载源码版本:android-12.0.0_r9
源码下载
温馨跳转
清华镜像源码下载教程
谷歌源码下载教程
个人总结源码下载
虽然在ubuntu可以科学上网,但是个人认为下载源码还是在清华镜像站tuna进行源码下载比较好,至于它的优点啊,相对快,相对稳定吧。
在下载源码前,首先提一下。
谷歌说,首先要了解特定设备的出厂映像,而非先了解如何下载源代码,请参阅选择设备编译系统。
简单来说,就是你下载的这套源码,在进行编译配置与选择lunch设备时,能不能找到你谷歌手机的代号。
个人经验:先在Android 源码代号列表查看你下载的源码版本是否支持你的设备,我一开始就犯了这个错,我下载了标记android-12.0.0_r13版本,结果我在我编译时,没有找到选项"lunch aosp_sargo-userdebug(Pixel 3a的代号为sargo)",折腾一天最后才发现下错源码了
build ID | 标记 | 版本 | 支持的设备 | 安全补丁程序级别 |
---|---|---|---|---|
SD1A.210817.036.A8 | android-12.0.0_r13 | Android12 | Pixel 6、Pixel 6 Pro | 2021-11-05 |
… | … | … | … | … |
SP1A.211105.002.A1 | android-12.0.0_r9 | Android12 | Pixel 3a、Pixel 3a XL、Pixel 4、Pixel 4a、Pixel 4a (5G)、Pixel 4 XL、Pixel 5、Pixel 5a (5G) | 2021-11-05 |
说一下repo的下载,以下方式个人不建议:
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
不建议的原因有:
- PATH=~/bin:$PATH 只在当前Terminal有效果,你重新打开另个一个Terminal,又得重新输入PATH=~/bin:$PATH,才可以使用repo,当然,你可以将~/bin增加ubuntu的环境变量
- 用repo init 命令时,没有科学上网会提示无法连接到 gerrit.googlesource.com.
基于上面两点,个人推荐使用tuna的git-repo镜像,下面我稍微修改了它的下载方式
1、
查看/usr/bin/或者/usr/local/bin是否有repo ,
如果有,请sudo cp /usr/bin/repo /usr/bin/repo_bak或者
sudo cp /usr/local/bin/repo /usr/local/bin/repo_bak
2、下载repo
sudo curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o /usr/bin/repo
#sudo curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o /usr/local/bin/repo
#这样我就不用配置PATH环境变量了,因为本来PATH都包括/usr/local/bin/和/usr/bin,可以echo $PATH查看
sudo chmod +x /usr/bin/repo
3、执行repo命令进行下载源码(记得装git,python,不然执行会报错)
#不执行,会提示“Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle”
#可把该执行放到~/.bashrc环境变量中
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-12.0.0_r9
上面-b参数后面的android 版本号,可以点此查看,android-12.0.0_r9(SP1A.211105.002.A1) 该版本支持我自己手机的pixel 3a
4、repo sync -j2
步骤3执行完毕后,再执行该命令。
对于参数-j2,可以选择-j4,但是我试过了,-j2比-j4稳定多了。(-j4会经常卡住)
5、对于,个人选择一种笨的办法,以下是我的脚本,和网上不一样
每隔3小时,中断一次repo sync,但是,当提示repo sync has finished successfully,只能通过ps 查看该脚本运行pid,并且kill该sh的脚本运行
#!/bin/bash
while [ 1 ]; do
timeout 3h repo sync -j2
echo "======every 3h,inturept sync,then re-sync again======"
done
谷歌手机设备驱动的下载
谷歌设备驱动下载
以下是我的手机pixel 3a的驱动文件下载
Pixel 3a binaries for Android 12.0.0 (SP1A.211105.002.A1)
Hardware Component | Company | Download |
---|---|---|
Vendor image | Link | |
GPS, Audio, Camera, Gestures, Graphics, DRM, Video, Sensors | Qualcomm | Link(这个不需要下载) |
然后你会得到一个tgz的压缩文件,把这个文件放到下载好的源码根目录,用tar -zxvf + 文件名,解压出来,得出一个sh文件,然后执行这个文件。我的是extract-google_devices-sargo.sh,执行命令为
./extract-google_devices-sargo.sh
其中在执行时,需要输入键盘ENTER和输入I ACCEPT
编译
谷歌编译流程
android 12.0的源码编译时,需要一些第三方编译库和工具,参考官网提供的编译环境,罗列个人在编译android 12,android 11,android 10,android 9所需要编译库与工具
sudo apt install python -y
sudo apt install libswitch-perl -y
sudo apt install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib -y
sudo apt install git flex bison gperf build-essential libncurses5-dev:i386 -y
sudo apt install dpkg-dev libsdl1.2-dev libesd0-dev -y
sudo apt install git-core gnupg -y
sudo apt install zlib1g-dev gcc-multilib -y
sudo apt install libc6-dev-i386 -y
sudo apt install lib32ncurses5-dev x11proto-core-dev libx11-dev -y
sudo apt install libxml2-utils xsltproc m4 -y
sudo apt install lib32z-dev ccache -y
sudo apt install python-markdown zlib1g-dev:i386 -y
sudo apt install libssl-dev -y
sudo apt install android-tools-fastboot -y
sudo apt install android-tools-adb -y
注:
#如果安装过程中发现"无法定位软件包"字,可进行如下
sudo apt install vim
#在/etc/apt 的sources.list末端添加镜像源
sudo vim /etc/apt 的sources.list
deb http://archive.ubuntu.com/ubuntu/ trusty main universe restricted multiversesudo apt-get update
进行编译
source ./build/envsetup.sh#Pixel 3a的产品代号为sargo
lunch aosp_sargo-userdebugmake update-api -j2 && make -j2
其中,在编译过程中,我用到-j4,-j8,老是提示内存不足,发现编译android 12需要快8G的内存,所以提高了VM的ubuntu的内存为8G,最后险编译通过
烧录
谷歌烧录教程
搭载ubuntu 系统的电脑通过USB连接设备pixel 3a
1、adb reboot bootloader(进行bootloader)
2、fastboot flashing unlock(不同设备OEM解锁,我在欧洲版Pixel 3a,bootloader是可以解锁的,至于其他设备的可以查看谷歌烧录教程)
3、source ./build/envsetup.sh(如果执行了,可以不用执行)
lunch aosp_sargo-userdebug(如果执行了,可以不用执行)
export ANDROID_PRODUCT_OUT=/home/fzc/study/android-12.0.0_r9/out/target/product/sargo(这个附上自己的源码pixel 3a代号sargo产物路径)
fastboot flashall -w
附上我成功烧录
android-12.0.0_r9$ fastboot flashall -w
--------------------------------------------
Bootloader Version...: b4s4-0.3-7357923
Baseband Version.....: g670-00116-210406-B-7261833
Serial Number........: 94LAY0QW31
--------------------------------------------
Checking 'product' OKAY [ 0.060s]
Setting current slot to 'a' OKAY [ 0.066s]
Sending 'boot_a' (65536 KB) OKAY [ 8.215s]
Writing 'boot_a' OKAY [ 0.430s]
Sending 'dtbo_a' (8192 KB) OKAY [ 1.100s]
Writing 'dtbo_a' OKAY [ 0.127s]
Sending 'vbmeta_a' (8 KB) OKAY [ 0.120s]
Writing 'vbmeta_a' OKAY [ 0.068s]
Rebooting into fastboot OKAY [ 0.060s]
< waiting for any device >
Sending 'system_a' (4 KB) OKAY [ 0.028s]
Updating super partition OKAY [ 0.054s]
Resizing 'product_a' OKAY [ 0.007s]
Resizing 'system_a' OKAY [ 0.006s]
Resizing 'system_ext_a' OKAY [ 0.013s]
Resizing 'vendor_a' OKAY [ 0.006s]
Resizing 'product_a' OKAY [ 0.006s]
Sending sparse 'product_a' 1/2 (262140 KB) OKAY [ 32.001s]
Writing 'product_a' OKAY [ 1.776s]
Sending sparse 'product_a' 2/2 (6948 KB) OKAY [ 0.891s]
Writing 'product_a' OKAY [ 0.133s]
Resizing 'system_a' OKAY [ 0.006s]
Sending sparse 'system_a' 1/4 (262140 KB) OKAY [ 31.700s]
Writing 'system_a' OKAY [ 1.845s]
Sending sparse 'system_a' 2/4 (262140 KB) OKAY [ 31.630s]
Writing 'system_a' OKAY [ 1.843s]
Sending sparse 'system_a' 3/4 (262140 KB) OKAY [ 32.274s]
Writing 'system_a' OKAY [ 1.876s]
Sending sparse 'system_a' 4/4 (25624 KB) OKAY [ 3.158s]
Writing 'system_a' OKAY [ 0.235s]
Resizing 'system_ext_a' OKAY [ 0.007s]
Sending 'system_ext_a' (126900 KB) OKAY [ 14.855s]
Writing 'system_ext_a' OKAY [ 0.997s]
Sending 'system_b' (72908 KB) OKAY [ 8.935s]
Writing 'system_b' OKAY [ 0.564s]
Resizing 'vendor_a' OKAY [ 0.005s]
Sending sparse 'vendor_a' 1/2 (262140 KB) OKAY [ 32.045s]
Writing 'vendor_a' OKAY [ 1.973s]
Sending sparse 'vendor_a' 2/2 (250144 KB) OKAY [ 30.937s]
Writing 'vendor_a' OKAY [ 1.780s]
Erasing 'userdata' OKAY [ 4.441s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Erasing 'metadata' OKAY [ 0.007s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Rebooting OKAY [ 0.003s]
Finished. Total time: 265.873s
注意:
- 烧录成功却无法正常开机,请检查谷歌手机设备驱动的下载是否错误。
- 烧录成功却无法正常开机,你可以去官网烧录将设备的出厂镜像(factory images),以便你正常开机使用
Android 12 源码下载、编译与烧录到Pixel 3a相关推荐
- android 12 源码编译与虚拟机调试
android 12 源码编译与虚拟机调试 android 12编译环境搭建 安装android 12环境依赖 android 12源码下载 下载repo工具 repo工具下载 国内repo工具修改 ...
- Android AOSP和Android-X86源码下载编译终极普法
Android AOSP和Android-X86源码下载编译终极普法 引言 最近有朋友在询问怎么下载Android AOSP源码和Android-X86源码,编译学习!其实这个说简单也简单 ...
- Android 12源码编译报错:FAILED: out/soong/build.ninja
Android 12源码编译报错:FAILED: out/soong/build.ninja android12源码编译中报如下错误: 网上查了比较多资料发现是swap分区不够导致的,报错时使用fre ...
- Ubuntu20.4 Android-9.0.0_r46源码下载编译
Ubuntu20.4 Android-9.0.0_r46源码下载编译调试 安装Ubuntu虚拟机 ubuntu镜像下载地址: https://ubuntu.com/download 官网下载地址较慢可 ...
- Android FrameWork学习(一)Android 7 0系统源码下载 编译
最近计划着研究下 Android 7.0 的系统源码,之前也没做过什么记录,这次正好将学习的内容记录下来,方便以后复习巩固. 既然要学习我们的系统源码,那我们第一步要做的就是下载源码并进行编译了. # ...
- linux编译android源码,ubuntu16.04 Android源码下载编译
本次编译源码的电脑为Ubuntu 16.04,4核 + 4G内存. 注. 对于电脑配置低的建议不要编译7.0以上的版本,就像我这台电脑,基本编译7.0以上都会报内存不足问题,因为在7.0版以上andr ...
- Android FrameWork学习(一)Android 7.0系统源码下载\编译
重点内容 转载. http://blog.csdn.net/cjpx00008/article/details/60474883 硬件环境要求 1. 编译环境 按照官方的说法,编译Android 2. ...
- Android系统源码下载与编译、刷机--Nexus6实测
前言 此博文记录一下Android从系统源码下载到刷机的全过程. (https://source.android.com/source/build-numbers.html 页面中列表信息找到自己设备 ...
- android 源码下载编译
引用:http://www.2cto.com/kf/201202/121175.html 最新的android4.0源代码公布以后,相信很多人和我一样都跃跃欲试,其实4.0的代码下载和编译和以前的版本 ...
- android 例子源码_AOSP系列文章(一)-Android系统源码下载和编译
前期准备 从这里开始,我们就去做android系统的修改,相信会有更多的同学有更多的玩法. android是开源的,在源代码里没有秘密. 同学们可以去修改系统,做成自己喜欢的样子.做汽车的车机,到家里 ...
最新文章
- AI落地遭“卡脖子”困境:为什么说联邦学习是解决良方?
- Science | 闵明玮等揭示细胞如何做出命运决定
- CUR分解算法及Python实现
- xamarin textview 滚动_Apple Music有原生滚动歌词了!喜大普奔!
- ‘FactorAnalyzer‘ object has no attribute ‘analyze‘和fa.loadings改成fa.loadings报错解决
- Code Names
- java连接ftp一直阻塞
- 把图标变成圆形的html_3组24个CSS3分享图标,可旋转和悬停
- oracle 表复制 long,【学习笔记】Oracle数据库使用copy实现long类型转移表空间案例 ORA-00997...
- C#之xml配置文件读写
- SEC0000007-Unable to locate security server?
- scrollTop如何实现click后页面过渡滚动到顶部
- cmake安装到指定目录
- PS/PR/AE全套插件一键安装包无需注册码
- 凯恩帝数控系统面板介绍_凯恩帝数控车床操作面板按钮详解!
- C++图形函数库EGE、raylib和EasyX及可以使用的开发工具小龙Dev-C++、小熊猫C++介绍
- 8脚 tja1050t_高速光耦:CAN总线通信硬件原理图(采用TJA1050T CAN总线驱
- mysql 查询view_MySQL之视图(VIEW)
- Cantor‘s paradox
- 2022年Google play admob AdSense 第三方收款指南
热门文章
- 网络操作系统项目教程----Windows server 2003篇----打印机安装与配置
- 衡量GDP,哪种夜间灯光数据更靠谱?
- 最实用的清理IE命令 ClearMyTracksByProcess
- 大数据驱动教育变革,产教融合呈现新高度——数据科学与大数据技术教育分论坛顺利召开...
- BUUCTF-Misc-sqltest(happyctf)
- 计算机232接口接线,RS232接口
- oracle 12c pdb数据库全库备份
- android 添加pdf字体,为Android添加多国语言包.pdf
- linux生成手机号码字典,字典生成器,木头超级字典生成器
- 计算机桌面的任务栏,计算机桌面出现两个任务栏怎么办?