学而不思则罔,思而不学则殆


【Android】Android源码下载

  • 一.环境准备
  • 虚拟机
  • Ubuntu系统
  • 二.Android源码下载
  • Ubuntu下载
  • 1.repo下载
  • 2.修改源代码镜像地址
  • 3.初始化仓库
  • 4.指定版本
  • 5.同步源码树
  • Windows下载
  • 1.repo下载
  • 2.修改源代码镜像地址
  • 3.初始化仓库
  • 4.指定版本
  • 5.同步源码
  • 6.错误



一.环境准备

虚拟机

vmware workstation 官网 或者百度网盘下载,包含14 15 16:

链接:https://pan.baidu.com/s/1Ozef4k06riePPFoKGyrkkA 
提取码:mmjr

Ubuntu系统

Ubuntu系统下载

或者百度网盘下载,包含14 16 18 20:

链接:https://pan.baidu.com/s/1CZ24djm1n4a63efyWYqGlA 
提取码:618z 

链接:https://pan.baidu.com/s/1CHjKrR6R2b5y9ZXpNxxTEQ 
提取码:vu6w 

链接:https://pan.baidu.com/s/1eIyvxVm9lJYyzGyvVkyaSw 
提取码:6wxl

二.Android源码下载

Ubuntu下载

1.repo下载

repo本质上一是python文件,用来管理多个git的一个工具。后面在Windows平台下通过repo下载源码也是这个原理。

# repo
## 在home下创建bin文件夹
mkdir ~/bin   
## 把bin文件夹加入环境变量的(临时的)
PATH=~/bin:$PATH   
## 下载repo脚本
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo  > ~/bin/repo 
#添加权限
chmod a+x ~/bin/repo

2.修改源代码镜像地址

此处用的是中国科学技术大学提供的镜像。
打开repo修改 REPO_URL = 'https://gerrit-googlesource.lug.ustc.edu.cn/git-repo'

3.初始化仓库

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

4.指定版本

Android源码有很多版本,从Android-1xx到Android-11xx.具体可以查看【Android】Android源码版本 ,来了解Android源码版本。

repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-2.0_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-2.1_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-2.2_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-2.3_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-4.0.1_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-5.0.0_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-6.0.0_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-7.0.0_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-7.1.1_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-8.0.0_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-8.1.0_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-9.0.0_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-10.0.0_r1
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-11.0.0_r1

5.同步源码树

repo sync

Windows下载

1.repo下载

在Windows平台下下载repo,通过命令行。注意,这里的文件后缀是py。

curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo.py

如图:

2016最新android源码 安卓源代码下载_android

2.修改源代码镜像地址

这里跟Ubuntu环境下下载一样

此处用的是中国科学技术大学提供的镜像。
打开repo修改 REPO_URL = 'https://gerrit-googlesource.lug.ustc.edu.cn/git-repo'

2016最新android源码 安卓源代码下载_2016最新android源码_02

3.初始化仓库

Windows环境下记得用管理员权限打开cmd.
Windows环境下记得用管理员权限打开cmd.
Windows环境下记得用管理员权限打开cmd.

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

初始化成功如下:

2016最新android源码 安卓源代码下载_python_03

4.指定版本

python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-2.0_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-2.1_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-2.2_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-2.3_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-4.0.1_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-5.0.0_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-6.0.0_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-7.0.0_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-7.1.1_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-8.0.0_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-8.1.0_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-9.0.0_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-10.0.0_r1
python repo.py init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-11.0.0_r1

成功如下:

2016最新android源码 安卓源代码下载_Android源码下载_04

5.同步源码

python repo.py sync

2016最新android源码 安卓源代码下载_2016最新android源码_05

然后就进入了漫长的等待中…

6.错误

中间可能遇到某些git库,下载失败,这个时候去default.xml文件中删除失败的git库后重新同步即可。
路径如下:

.repo\manifests\default.xml