Android aosp源码阅读
Posted Notzuonotdied
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android aosp源码阅读相关的知识,希望对你有一定的参考价值。
前言
最近因为找工作,需要频繁查阅android源码。因此,打算在本地硬盘上下载Android源码,通过Android Studio来阅读。
- Android 源码构建:https://source.android.com/setup【建议直接阅读该文档】
- Android - AOSP源码编译和调试
操作流程
配置硬盘
由于我使用的是MacOS,所以仅提供MacOS的配置流程。
- 打开Disk Utility
- File -> New Image -> Blank Image
- 按照下图配置一块200G,区分大小写的磁盘分区。
- 一定要区分大小写,否则下载源码后,占用空间极大。
- 区分大小写后,Android 12的源码大小为139GB;不区分大小写,占用空间超过700GB。
下载源码
下载Android系统源代码:建议按照清华大学开源软件镜像站文档下载源码。
- 如果需要下载指定版本的源码,tag可见:源代码标记和 build
生成
- 初始化环境变量:
source build/envsetup.sh
- 编译,生成idegen.jar:
mmm development/tools/idegen/
- 生成android.iws、android.ipr、android.iml:
sh ./development/tools/idegen/idegen.sh
排除部分模块
打开android.iml,提前添加如下内容,提高加载Android源码工程的速度。
<excludeFolder url="file://$MODULE_DIR$/.repo" />
<excludeFolder url="file://$MODULE_DIR$/abi" />
<excludeFolder url="file://$MODULE_DIR$/art" />
<excludeFolder url="file://$MODULE_DIR$/bionic" />
<excludeFolder url="file://$MODULE_DIR$/bootable" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/cts" />
<excludeFolder url="file://$MODULE_DIR$/dalvik" />
<excludeFolder url="file://$MODULE_DIR$/developers" />
<excludeFolder url="file://$MODULE_DIR$/development" />
<excludeFolder url="file://$MODULE_DIR$/device" />
<excludeFolder url="file://$MODULE_DIR$/docs" />
<excludeFolder url="file://$MODULE_DIR$/external" />
<excludeFolder url="file://$MODULE_DIR$/external/bluetooth" />
<excludeFolder url="file://$MODULE_DIR$/external/chromium" />
<excludeFolder url="file://$MODULE_DIR$/external/emma" />
<excludeFolder url="file://$MODULE_DIR$/external/icu4c" />
<excludeFolder url="file://$MODULE_DIR$/external/jdiff" />
<excludeFolder url="file://$MODULE_DIR$/external/webkit" />
<excludeFolder url="file://$MODULE_DIR$/frameworks/base/docs" />
<excludeFolder url="file://$MODULE_DIR$/hardware" />
<excludeFolder url="file://$MODULE_DIR$/libcore" />
<excludeFolder url="file://$MODULE_DIR$/libnativehelper" />
<excludeFolder url="file://$MODULE_DIR$/ndk" />
<excludeFolder url="file://$MODULE_DIR$/out" />
<excludeFolder url="file://$MODULE_DIR$/out/eclipse" />
<excludeFolder url="file://$MODULE_DIR$/out/host" />
<excludeFolder url="file://$MODULE_DIR$/out/target/common/docs" />
<excludeFolder url="file://$MODULE_DIR$/out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates" />
<excludeFolder url="file://$MODULE_DIR$/out/target/product" />
<excludeFolder url="file://$MODULE_DIR$/packages" />
<excludeFolder url="file://$MODULE_DIR$/pdk" />
<excludeFolder url="file://$MODULE_DIR$/prebuilt" />
<excludeFolder url="file://$MODULE_DIR$/prebuilts" />
<excludeFolder url="file://$MODULE_DIR$/sdk" />
<excludeFolder url="file://$MODULE_DIR$/system" />
<excludeFolder url="file://$MODULE_DIR$/tools" />
附录
国内源
调试Framework
以上是关于Android aosp源码阅读的主要内容,如果未能解决你的问题,请参考以下文章