国内被墙后如何获取android源代码

按照http://source.android上的步骤并不能获取android源代码,估计又是被墙了。不过经过研究发现可以从一些镜像站点上获取android源代码

Step 1.按照 http://source.android/source/initializing.html配置好android编译环境 Step 2.按照 http://source.android/source/downloading.html配置好repo,大概步骤如下
       $ mkdir ~/bin    $ PATH=~/bin:$PATH    $ curl https://dl-ssl.google/dl/googlesource/git-repo/repo > ~/bin/repo    $ chmod a+x ~/bin/repo    $ mkdir WORKING_DIRECTORY    $ cd WORKING_DIRECTORY    以上命令不再解释,很简单很明白。      Setp 3.从其他镜像获取源代码    如果要下载最新的源代码,则执行:   $ repo init -u git:// git.omapzoom /platform/manifest     如果要获取每个tag,譬如2.3.5,则可以执行:      $ repo init -u git:// git.omapzoom /platform/manifest -b android-2.3.5_r1    如果你不知道具体的tag叫什么名字,那么可以在浏览器访问http://git.omapzoom,并点击上面的 /platform/manifest 链接,那么可以看到所有的tag名称.     执行repo init过程中,可能需要填写一些个人信息,直接填写即可。     配置好repo后,执行repo sync即可下载你所需要的源代码了。


下载代码出错

error: Failed to connect to 2404:6800:4005:c00::52: Network is unreachable while accessing https://android.googlesource/mirror/manifest/info/refs
fatal: HTTP request failed

解决方法

1. 浏览器登录https://android.googlesource/new-password,并用gmail帐号登录;

2. 点击网页上的“允许访问”,得到类似

 
  1. machine android.googlesource login git-jacky.rg4 password 1/dkRiGEvvC8o8Pgg-GsM2AbMNS_32-U0Pf0_VWkYogIA 
  2. machine android-review.googlesource login git-jacky.rg4 password 1/dkRiGEvvC8o8Pgg-GsM2AbMNS_32-U0Pf0_VWkYogIA 

3. 把上面那段信息追加到~/rc文件结尾(请检查当前用户的权限, 如果不存在此文件则自己新建一个);

4. 下载地址的URI更改为https://android.googlesource/a/platform/manifest(中间加上了“/a”)。

5. repo init -u https://android.googlesource/a/platform/manifest -b android-4.0.3_r1

6. repo sync

即可拉下Android源码。

官方的说法是:因为访问基本是匿名的,为了防止连接过多(指内网/虚拟机),对同一IP地址的连接数做了一定的限制。看来是用gmail帐号进行认证。

这样的话,在公司网络内或者用虚拟机下载的话,会经常遇到这问题。

源码官网指导网址: http://source.android/source/downloading.html



查看Android源码版本

$ grep PLATFORM_VERSION build/core/version_defaults.mk
#     PLATFORM_VERSION
#     PLATFORM_VERSION_CODENAME
ifeq "" "$(PLATFORM_VERSION)"
  PLATFORM_VERSION := 4.1.2
  # SDK version the branch is based on and PLATFORM_VERSION_CODENAME holds
ifeq "" "$(PLATFORM_VERSION_CODENAME)"
  PLATFORM_VERSION_CODENAME := REL
  ifeq "REL" "$(PLATFORM_VERSION_CODENAME)"
    DEFAULT_APP_TARGET_SDK := $(PLATFORM_VERSION_CODENAME)


断网时自动进行repo sync继续下载android源码


症状分析: 在Android源码下载时,经常会断掉,这时,就得重新输入repo sync,那么,有没有一种方法在断网时自动进行repo sync呢? 

解决对策:

vi  repo_sync.sh

#!/bin/bash
repo sync
while [ $? -ne 0 ]
do
repo sync
done


ubuntu10.04 amd64 git版本升级,error: Exited sync due to gc errors

ubuntu10.04出现error:Exited sync due to gc errors解决方法
 
error: Exited sync due to gc errors 解决方法
 
原因: repo 升级,不兼容GIT  1.7.2 以下的版本。

升级git到 1.7.2以及以上的版本, 升级方法 
 
增加ppa 
sudo apt-add-repository ppa:git-core/ppa 
sudo apt-get update 
sudo apt-get install git 
 
如果本地已经安装过Git,可以使用升级命令: 
sudo apt-get dist-upgrade


 


更多推荐

下载android源码