惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
P
Privacy International News Feed
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 叶小钗
F
Fortinet All Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 最新话题
AWS News Blog
AWS News Blog
Engineering at Meta
Engineering at Meta
Attack and Defense Labs
Attack and Defense Labs
Recent Announcements
Recent Announcements
Recent Commits to openclaw:main
Recent Commits to openclaw:main
PCI Perspectives
PCI Perspectives
Cloudbric
Cloudbric
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
IT之家
IT之家
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
J
Java Code Geeks
M
MIT News - Artificial intelligence
Cisco Talos Blog
Cisco Talos Blog
V2EX - 技术
V2EX - 技术
Webroot Blog
Webroot Blog
Microsoft Security Blog
Microsoft Security Blog
Cyberwarzone
Cyberwarzone
博客园 - 聂微东
G
Google Developers Blog
W
WeLiveSecurity
罗磊的独立博客
P
Privacy & Cybersecurity Law Blog
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
T
Tailwind CSS Blog
V
Visual Studio Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Secure Thoughts
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
Google DeepMind News
Google DeepMind News
Google DeepMind News
Google DeepMind News
雷峰网
雷峰网
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
F
Full Disclosure
Blog — PlanetScale
Blog — PlanetScale
The Last Watchdog
The Last Watchdog
P
Proofpoint News Feed

chenhang 的博客

Android 12 - WMS 层级结构 && DisplayAreaGroup 引入 Android 12 - 跟踪利器 WinScope Android 12 - Letterbox 模式 Android 列表滚动优化之 OverScroller 揭秘 使用 Ninja 提升模块编译速度 Android Q 黑暗模式(Dark Mode)源码解析 如何顺滑地查看 Android Native 代码 Protocol Buffers 手册 设计模式之装饰模式 设计模式之桥接模式 设计模式之代理模式 依赖注入利器 - Dagger ‡ Robolectric使用教程 设计模式之模板方法模式和策略模式 设计模式之工厂模式(Factory) Fragment源码分析 Fragment事务管理源码分析 java动态代理 Android分包MultiDex源码分析
AOSP 编译和烧写
2019-09-12 · via chenhang 的博客

1. 简介

很多 Android 开发者都会希望编译 Android 源码并刷进自己的手机里面,但网上教程很多都仅仅是告诉你 lunch、make 等等,但你手里有一台设备时却发现,你编译出的镜像由于驱动关系是不能直接烧进手机的。这里整理了一下步骤,帮助大家可以按照流程编译并烧写镜像。

本篇文章以 Pixel 2 && Android 10 为例

2. 环境准备

这块没啥说,官方教程就够了,参考:https://source.android.com/setup/build/initializing 就行了

3. 源码下载

  1. 根据 https://developers.google.com/android/drivers 选择一个设备对应 Android 版本号和驱动,比如我们选择:Android 10.0.0 (QP1A.190711.020),下载驱动,记住 Build 号
    2019-9-12-16-53-40.png
  1. https://source.android.com/setup/start/build-numbers 查找 QP1A.190711.020 对应的分支:android-10.0.0_r2,记住分支名
    2019-9-12-16-56-41.png

  2. 下载 AOSP 源码
    注意在下载 aosp 前要安装 repo 工具,参考:https://source.android.com/setup/build/downloading

    1
    2
    3
    4
    5
    mkdir Pixel2
    cd Pixel2
    repo init -u https://android.googlesource.com/platform/manifest -b android-10.0.0_r2 --depth=1
    repo sync -j8
    repo start android-10.0.0_r2 --all
  3. 把步骤1中选中的两个驱动下载到 aosp 源码根目录并解压

  4. 分别执行解压后的文件,注意,执行后要同意 License,确保正确解压到 aosp 根目录的 vendor 目录

    1
    2
    ./extract-qcom-walleye.sh
    ./extract-google_devices-walleye.sh

4. 源码编译

  1. 在 aosp 源码根目录执行:source build/envsetup.sh(注意,执行前终端请选bash,不要使用zsh等,在终端键入bash回车即可)
  2. 在 aosp 源码根目录执行:lunch
  3. 选择对应的版本,比如 Pixel2 就选择:aosp_walleye-userdebug
  4. 执行:make -j8

5. 镜像烧写

  1. 编译完后,执行:export ANDROID_PRODUCT_OUT=/home/chenhang/source/Pixel2/out/target/product/walleye
  2. 执行:fastboot flashall -w
  3. 烧写完成后,执行:fastboot reboot

6. Gapps 安装

编译出来的 aosp 默认没有 google 全家桶,可以通过以下方式进行安装

  1. https://opengapps.org/ 根据系统版本、芯片类型选择需要的 Gapps 全家桶,可以选 stock 版本
  2. 下载后把全家桶 push 到手机 sdcard(不用解压)
  3. https://twrp.me/devices/ 搜索你的设备,如: https://twrp.me/google/googlepixel2.html
    2019-9-12-17-3-22.png
  4. 下载 twrp.img 后根据截图中的命令,把 twrp 加载到手机, 选择 install 刷入 twrp.zip (这是一个 recovery 版本),重启后,通过 adb reboot recovery 进入 twrp 的recovery 系统
  5. 在手机上选择 install, 选择步骤2中 push 到手机 sdcard 的全家桶,安装结束后选择擦除 dalvik cache 和 cache,重启即可

chenhang wechat