AOSP : Android源码下载

前言

Linux 环境:

现在WIN10内置Ubuntu方便使用

AOSP

AOSP(Android Open Source Project)是Google开放的Android 开源项目,中文官网为:https://source.android.google.cn/
国内获取AOSP源镜像源:清华大学镜像站中科大镜像

AOSP Google 官方教程下载 https://source.android.com/source/downloading.html
网站直接查看代码:

AOSP | 镜像站使用帮助 | 清华大学开源软件镜像站

按照“镜像站使用帮助”说明就可以了

需要注意:
1、Ubuntu更换国内源
#先备份原来的源列表文件
mv /etc/apt/sources.list /etc/apt/sourses.list.backup
#新建源列表文件
vim /etc/apt/sources.list

#加入源地址(推荐用阿里云源)

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

#更新软件列表
sudo apt-get update
#更新软件(把已安装的软件与刚刷新的软件列表中的版本进行对比,如果发现已安装的软件版本太低,就会提示更新)
sudo apt-get upgrade


2、下载 git、repo工具

sudo apt-get install git
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

3、配置gitconfig
git config --global user.email xhbruce@foxmail.com
git config --global user.name xhbruce

xuhun@Bruce-xu:/mnt/d/AOSP/android-10.0.0_r36/frameworks/base$ git config --global --list
core.filemode=false
core.autocrlf=true
user.email=xbruce@foxmail.com
user.name=xbruce

4、可下载android-10.0.0_r36

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-10.0.0_r36

5、替换已有的 AOSP 源代码的 remote
如果你之前已经通过某种途径获得了 AOSP 的源码(或者你只是 init 这一步完成后), 你希望以后通过 TUNA 同步 AOSP 部分的代码,只需要将 .repo/manifest.xml 把其中的 aosp 这个 remote 的 fetch 从 https://android.googlesource.com 改为 https://mirrors.tuna.tsinghua.edu.cn/git/AOSP。

<manifest>

  <remote  name="aosp"
-           fetch="https://android.googlesource.com"
+           fetch="https://mirrors.tuna.tsinghua.edu.cn/git/AOSP"
           review="android-review.googlesource.com" />

  <remote  name="github"

同时,修改 .repo/manifests.git/config,将

url = https://android.googlesource.com/platform/manifest

更改为

url = https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest

推荐使用单仓下载

对绝大多数人查看Android源码不会涉及全部代码,一般需要platform/frameworks/base 和 platform/frameworks/native

初始化仓库:

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest

下载单仓platform/frameworks/base 和 platform/frameworks/native:

repo sync platform/frameworks/base
repo sync platform/frameworks/native

参看对应分支

git branch -a
git branch -a |grep android11-

在这里插入图片描述

切换到对应分支,如remotes/aosp/android11-release
git checkout -b android11-release remotes/aosp/android11-release

在这里插入图片描述

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xhBruce

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值