android源码在线阅读网站:
xref:https://xrefandroid.com/(有时候访问不了)
androidxref:http://androidxref.com/(只能到android9)
在线看android源码不方便 因此我们可以选择把android源码下载到本地
可以使用清华镜像AOSP下载方式:https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/
先尝试在window环境下下载:
1、先下载curl工具配置到环境变量
2、使用curl工具curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo > D:\SoftWare\repo 下载到本地(本人电脑没法上外网 所以repo也是下载的清华镜像的)
3、把manifest文件下载下来 看一下有哪些分支
使用git时候记得配置git
git config --global user.name "git username"
git config --global user.email "xxxxxxxxqq.com"
直接git clone https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest 下载下来这个
window环境下 我就用python命令执行的
cd manifest中 git branch -a 查看所有分支
我们要去下载android15的源码
3、python 执行repo命令下载。不好意思,失败了,卡在了客户端没有特权
那windows下载没成功 改为linux试试:
下载VMware虚拟机:
VMware被broadcom收购了 所以需要先注册个账号:
https://support.broadcom.com/ 右上角register,巴啦啦的填了信息
下载的网址:https://support.broadcom.com/group/ecx/productdownloads?subfamily=VMware%20Workstation%20Pro
下载的时候还要填信息,还得承诺不对老美造成危害 还不要用于核武器等研发(我倒是想)
右边点击云的箭头就去下载了
好了VMware下载了 我们要去下载个ubuntu镜像
还是清华镜像网站:https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/24.04.1/
安装好VMware用镜像创建好虚拟机之后,准备环境
sudo apt-get install git
mkdir ~/bin
PATH=~/bin:$PATH
sudo apt-get install curl
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod a+x ~/bin/repo
sudo apt-get install python3
重启虚拟机,这样repo才能生效
mkdir aosp
cd aosp
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
git config --global user.name "git username"
git config --global user.email "xxxxxxxxqq.com"
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest/ -b android-14.0.0_r75
初始化仓库后,会提示repo has been initialized in 你的路径
使用命令repo sync开始同步android源码
AOSP中不包括内核源码
下载kernel源码也可以使用清华镜像网站,具体就是git clone goldfish git branch看有哪些分支 最后git checkout 分支 来下载
还要一种方法可以下载源码:直接使用git
通过repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest/ 获得manifest后,文件夹下有个default.xml目录 此目录表示AOSP包含得子项目,如package、framework等
我们可以直接拼出来project路径 用git clone下来
如:https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/frameworks/base
git clone https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/frameworks/base
下载好后,进入base文件夹下 git checkout 分支 完成子项目framework/base下载