之前我是去Android官方网站下载最新Android代码,但是这种方法需要翻墙,而且有时候翻墙又不太方便,今天我发现一个不错的网站,是清华大学搞的,跟Android官方的代码基本保持同步,而且下载方法跟Android官方的也类似。下面是网站地址:

https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/

下面我简单介绍一下几种下载方法:

准备工作

方法一

  • 下载repo工具
   1: mkdir ~/bin

   2: PATH=~/bin:$PATH

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

   4: chmod a+x ~/bin/repo

  • 建立工作目录
   1: mkdir WORKING_DIRECTORY

   2: cd WORKING_DIRECTORY

  • 初始化仓库
   1: repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest

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

   3: REPO_URL = 'https://gerrit-google.tuna.tsinghua.edu.cn/git-repo'

  • 同步源码树
   1: repo sync

方法二 建立本地镜像

重点说一下这种方法,这种方法首先在本地建立一个Andriod代码的镜像,第一次需要下载大量的代码(我的占了120GB左右的空间),然后执行类似方法一,不过这次的Android代码源是在本地,所以速度很快。以后更新的时候,先更新本地Andriod代码镜像,再更新Android代码。我用的就是这种方法,我的代码镜像是翻墙的时候从Android官方下载的,所以每次更新Android代码镜像的时候都需要翻墙,不方便。

步骤:

  • 下载 repo 工具和建立工作目录 (参照方法一)

这里需要修改一下repo工具:

   1: REPO_URL = 'https://gerrit.googlesource.com/git-repo'

修改为:

   1: REPO_URL = 'https://gerrit-google.tuna.tsinghua.edu.cn/git-repo'

  • 初始化
   1: repo init -u https://aosp.tuna.tsinghua.edu.cn/mirror/manifest --mirror

  • 同步源码树
   1: repo sync

然后,就可以从本地sync代码了:

   1: repo init -u WORKING_DIR/mirror/platform/manifest.git

   2: repo sync

下面是Android官方的说明:

Using a local mirror

When using several clients, especially in situations where bandwidth is scarce, it is better to create a local mirror of the entire server content, and to sync clients from that mirror (which requires no network access). The download for a full mirror is smaller than the download of two clients, while containing more information.

These instructions assume that the mirror is created in /usr/local/aosp/mirror. The first step is to create and sync the mirror itself. Notice the --mirror flag, which can be specified only when creating a new client:

$ mkdir -p /usr/local/aosp/mirror
$ cd /usr/local/aosp/mirror
$ repo init -u https://android.googlesource.com/mirror/manifest --mirror
$ repo sync

Once the mirror is synced, new clients can be created from it. Note that it's important to specify an absolute path:

$ mkdir -p /usr/local/aosp/master
$ cd /usr/local/aosp/master
$ repo init -u /usr/local/aosp/mirror/platform/manifest.git
$ repo sync

Finally, to sync a client against the server, the mirror needs to be synced against the server, then the client against the mirror:

$ cd /usr/local/aosp/mirror
$ repo sync
$ cd /usr/local/aosp/master
$ repo sync

It's possible to store the mirror on a LAN server and to access it over NFS, SSH or Git. It's also possible to store it on a removable drive and to pass that drive around between users or between machines.

更新本地Android镜像

由于我最初的Android镜像来自Android官方,需要翻墙,所以需要作如下修改:

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

   1: <manifest>

   2:  

   3:    <remote  name="aosp"

   4: -           fetch="https://android.googlesource.com"

   5: +           fetch="https://aosp.tuna.tsinghua.edu.cn"  或 "git://aosp.tuna.tsinghua.edu.cn/aosp"

   6:             review="android-review.googlesource.com" />

   7:  

   8:    <remote  name="github"

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

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

更改为

   1: url = https://aosp.tuna.tsinghua.edu.cn/platform/manifest

   2: # 或 url = git://aosp.tuna.tsinghua.edu.cn/aosp/platform/manifest

完。

下载最新Android代码的方法的更多相关文章

  1. 下载最新android adt的方法

    作为一名android开发人员,需要经常更新最新版本的 android adt,但是直接到官网去找很难找到下载的链接,通过下面现成的链接,你就能够直接下载最新的android adt了, 网址是:de ...

  2. repo 工具下载 以及 android代码下载【转】

    本文转载自:http://www.enjoydiy.com/608.html 我们可以从https://www.codeaurora.org/网站下载android源码. 具体方法如下: 下载repo ...

  3. 通过镜像下载最新Android源码

    参考了这两篇博客: http://blog.sina.com.cn/s/blog_70b9730f01016peg.html http://www.cnblogs.com/act262/p/41790 ...

  4. android代码格式化方法小结

    转载:http://blog.csdn.net/androidzhaoxiaogang/article/details/7692526 Download the android-formatting. ...

  5. Android代码混淆官方实现方法

    首先查看一下 “project.properties” 这个文件: # This file is automatically generated by Android Tools.# Do not m ...

  6. LINUX安装SVN+添加自动同步+远程下载最新代码

    LINUX安装SVN+添加自动同步+远程下载最新代码---------------------1. 新建一个用户:svnroot ,以下操作非特别说明皆为root用户操作--------------- ...

  7. 将应用代码由eclipse导入Android studio的方法NDK-Build和Cmake两种方法(以android_serialport_api为例)

    网上翻了几百篇博客,看了半天,要不就是写的乱七八糟看不懂,要不就是隐藏了一些细节,要不就是实现不了,最后还是在Android官网上看明白了,而且说得有条有理,以后遇到不懂的一定要先翻官网. 参考资料: ...

  8. IntelliJ Idea 依赖包下载成功,代码里无法import问题解决方法

    今天clone一个github上的基于maven的项目IntelliJ Idea 依赖包下载成功,代码里无法import.解决方法:删掉原来的.iml,刷新. 如果不行,可尝试:File->In ...

  9. Android代码混淆及项目发布方法记录

     Android代码混淆及项目发布步骤记录 本来整理了一份Android项目混淆与发布的文档,突然想到何不写篇博客,分享一下呢,如是便有了本文. Android代码混淆及项目发布步骤记录 一.清理 ...

随机推荐

  1. [原创]软件质量保证圈QQ群:197915314

    [原创]软件质量保证圈QQ群:197915314 软件质量保证圈QQ群:197915314,讨论软件工程.软件过程改进.软件质量保证等(非测试群)! 欢迎各位同学来,来时请自报家门,名片修改格式:sh ...

  2. lpxelinux启动linux

          搭建环境: boot file 指定 lpxelinux.0 拷贝 lpxelinux.0 和 ldlinux.c32 到 tftp目录下. 新建pxelinux.cfg 文件夹, 里面放 ...

  3. 解决ASP.NET在IE10中Session丢失问题【转】

    今天发现在IE10中登录我公司的一个网站时,点击其它菜单,页面总会自动重新退出到登录页,后检查发现,IE10送出的HTTP头,和.AUTH Cookie都没问题,但使用表单验证机制(FormsAuth ...

  4. iis 故障导致网站无法访问

    服务器使用两三个月突然,昨天无法访问,重启后正常,第二次发生这样的事情了,打开  C:\WINDOWS\system32\LogFiles\HTTPERR  下的   httperr1.txt 201 ...

  5. 解决 01-Jul-2016 10:49:05.875 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [com.mysql.jdbc.D

    01-Jul-2016 10:49:05.875 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoade ...

  6. Oracle 11g 的官方支持周期和时限

    Oracle公司对于自身产品的支持策略大多数人很难搞清楚,对于Oracle Database 11g的支持周期,有很多朋友产生了异议,参考下文提到的一些文件,希望可以帮助大家理解Oracle的产品支持 ...

  7. Android 多线程-----AsyncTask详解

    您可以通过点击 右下角 的按钮 来对文章内容作出评价, 也可以通过左下方的 关注按钮 来关注我的博客的最新动态. 如果文章内容对您有帮助, 不要忘记点击右下角的 推荐按钮 来支持一下哦 如果您对文章内 ...

  8. discuz 使用阿里云OSS

    discuz 使用阿里云OSS (转)http://bbs.aliyun.com/read/239257.html 说明:我绑定了二级域名,本演示采用二级域名oss来介绍,我实际使用的是二级域名pic ...

  9. Andriod调用http请求

    // 新建HttpPost对象 HttpPost httpPost = new HttpPost( "http://180.153.1.1:8080/mybankGateway/gatewa ...

  10. ASP.NET MVC 入门8、ModelState与数据验证

    原帖地址:http://www.cnblogs.com/QLeelulu/archive/2008/10/08/1305962.html ViewData有一个ModelState的属性,这是一个类型 ...