您的位置:首页 > 移动开发 > Android开发

【Android源码】如何下载Android源代码

2018-03-10 21:28 197 查看
对于下载源代码这种操作,官方给的说明确实也是很详细。但是奈何GFW。所以用国内的源跑得比什么都快。网上也有很多教程,但是这些感觉是copy——因为它们都比不上国内源的网站上给的操作说明。

国内有哪些Android的镜像源

1. 中国科技大学

2. 清华大学

从上面的两个链接直接点进去便是帮助文档,跟着帮助文档一步一步走就OK了。但是我还是想偷一下懒。。。也许有一天我并不想点这两个链接,那就看下面吧。

下载步骤(同AOSP(Android) 镜像使用帮助)

按照 Google 官方教程 https://source.android.com/source/downloading.html

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


替换为
git://mirrors.ustc.edu.cn/aosp/platform/manifest


具体做法摘录如下(以防墙抽风):

1. 首先下载 repo 工具。

mkdir ~/bin


PATH=~/bin:$PATH


curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo


如果上述 URL 不可访问,可以用下面的:

curl https://storage-googleapis.proxy.ustclug.org/git-repo-downloads/repo > ~/bin/repo


chmod a+x ~/bin/repo


2. 然后建立一个工作目录(名字任意)

mkdir WORKING_DIRECTORY


cd WORKING_DIRECTORY


3. 初始化仓库:

repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest


如果提示无法连接到
gerrit.googlesource.com
,可以编辑
~/bin/repo
,把 REPO_URL 一行替换成下面的:

REPO_URL = 'https://gerrit-googlesource.proxy.ustclug.org/git-repo'


如果需要某个特定的 Android 版本(Android 版本列表):

repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-4.0.1_r1


4. 同步源码树(以后只需执行这条命令来同步):

repo sync


5. 已有仓库如何改用科大源

如果您已经从官方同步了 AOSP 仓库,现在希望使用科大的 AOSP 仓库,请修改
.repo/manifests.git/config
,将

url = https://android.googlesource.com/platform/manifest[/code] 
修改成

url = git://mirrors.ustc.edu.cn/aosp/platform/manifest


即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 源码