下载 Android 指定版本源码

1、安装 git  、curl
$ sudo apt-get install git curl
2、安装 repo
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
3、指定源码下载目录
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
4、下载git仓库Android清单
$ sudo git clone  https://android.googlesource.com/platform/manifest
5、查看当前清单中的Android版本信息,可以看出当前默认获取的版本为 master
$ cd manifest
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/android-1.6_r1
  remotes/origin/android-1.6_r1.1
  remotes/origin/android-1.6_r1.2
  remotes/origin/android-1.6_r1.3
  remotes/origin/android-1.6_r1.4
  remotes/origin/android-1.6_r1.5
  remotes/origin/android-1.6_r2
  remotes/origin/android-2.0.1_r1
  remotes/origin/android-2.0_r1
  remotes/origin/android-2.1_r1
  remotes/origin/android-2.1_r2
  remotes/origin/android-2.1_r2.1p
  remotes/origin/android-2.1_r2.1p2
  remotes/origin/android-2.1_r2.1s
  remotes/origin/android-2.2.1_r1
  remotes/origin/android-2.2.1_r2
  remotes/origin/android-2.2.2_r1
  remotes/origin/android-2.2.3_r1
  remotes/origin/android-2.2.3_r2
  remotes/origin/android-2.2.3_r2.1
  remotes/origin/android-2.2_r1
  remotes/origin/android-2.2_r1.1
  remotes/origin/android-2.2_r1.2
  remotes/origin/android-2.2_r1.3
  remotes/origin/android-2.3.1_r1
  remotes/origin/android-2.3.2_r1
  remotes/origin/android-2.3.3_r1
  remotes/origin/android-2.3.3_r1.1
  remotes/origin/android-2.3.4_r0.9
  remotes/origin/android-2.3.4_r1
  remotes/origin/android-2.3.5_r1
  remotes/origin/android-2.3.6_r0.9
  remotes/origin/android-2.3.6_r1
  remotes/origin/android-2.3.7_r1
  remotes/origin/android-2.3_r1
  remotes/origin/android-4.0.1_r1
  remotes/origin/android-4.0.1_r1.1
  remotes/origin/android-4.0.1_r1.2
  remotes/origin/android-4.0.2_r1
  remotes/origin/android-4.0.3_r1
  remotes/origin/android-4.0.3_r1.1
  remotes/origin/android-4.0.4_r1
  remotes/origin/android-4.0.4_r1.1
  remotes/origin/android-4.0.4_r1.2
  remotes/origin/android-4.0.4_r2
  remotes/origin/android-4.0.4_r2.1
  remotes/origin/android-4.1.1_r1
  remotes/origin/android-4.1.1_r1.1
  remotes/origin/android-4.1.1_r2
  remotes/origin/android-4.1.1_r3
  remotes/origin/android-4.1.1_r4
  remotes/origin/android-4.1.1_r5
  remotes/origin/android-4.1.1_r6
  remotes/origin/android-4.1.1_r6.1
  remotes/origin/android-4.1.2_r1
  remotes/origin/android-4.2.1_r1
  remotes/origin/android-4.2.1_r1.1
  remotes/origin/android-4.2.1_r1.2
  remotes/origin/android-4.2.2_r1
  remotes/origin/android-4.2_r1
  remotes/origin/android-cts-2.2_r8
  remotes/origin/android-cts-2.3_r10
  remotes/origin/android-cts-2.3_r11
  remotes/origin/android-cts-2.3_r12
  remotes/origin/android-cts-4.0.3_r1
  remotes/origin/android-cts-4.0.3_r2
  remotes/origin/android-cts-4.0_r1
  remotes/origin/android-cts-4.1_r1
  remotes/origin/android-cts-4.1_r2
  remotes/origin/android-cts-4.2_r2
  remotes/origin/android-cts-verifier-4.0.3_r1
  remotes/origin/android-cts-verifier-4.0_r1
  remotes/origin/android-sdk-4.0.3-tools_r1
  remotes/origin/android-sdk-4.0.3_r1
  remotes/origin/android-sdk-adt_r16.0.1
  remotes/origin/android-sdk-adt_r20
  remotes/origin/android-sdk-support_r11
  remotes/origin/froyo
  remotes/origin/gingerbread
  remotes/origin/gingerbread-release
  remotes/origin/ics-mr0
  remotes/origin/ics-mr1
  remotes/origin/ics-plus-aosp
  remotes/origin/jb-dev
  remotes/origin/jb-mr1-dev
  remotes/origin/jb-mr1-dev-plus-aosp
  remotes/origin/jb-mr1.1-dev
  remotes/origin/jumper-stable
  remotes/origin/master
  remotes/origin/master-dalvik
  remotes/origin/tools_r20
  remotes/origin/tools_r21
  remotes/origin/tools_r21.1
  remotes/origin/tools_r22
  remotes/origin/tradefed
6、下载指定版本源码,参数 -b 后为指定版本号,可根据第5步获得。
$ sudo repo init -u https://android.googlesource.com/platform/manifest -b android-2.2.2_r1
$ repo sync

参考地址:

Android 官方下载源码指导

查看 android 现在有什么分支

你可能感兴趣的:(下载 Android 指定版本源码)