Ubuntu 10.04 下载android 4.1.1_r4

一、安装 curl git

    $ sudo apt-get install  curl

    $ sudo apt-get install git-core

二、安装repo

1.在主目录(~)建立目录 bin/,并包含在PATH环境变量中

   $ sudo mkdir ~/bin

   $ sudo chmod  777 ~/bin

   $ PATH=~/bin/:PATH

2.下载repo,并赋予其可执行权限

   $ curl   https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
   $ sudo chmod a
+x ~/bin/repo

三、初始化repo客户端

1.建立一个工作目录,用于存放下载的android 源码文件

   $ sudo mkdir /home/source-android_4.1.1_r4

   $ sudo chmod  777 /home/source-android_4.1.1_r4

2.check out  android 的一个分支

  $ cd /home/source-android_4.1.1_r4

  $ repo init -u https://android.googlesource.com/platform/manifest -b android-4.1.1_r4

3. git 会提示出现需要一个google 的账户,可以照如下配置

  $ git config user.exmail "xxxxxx@gmail.com"

  $ git config user.name "Xxxx Xx"

   然后,再执行一次下面的命令

  $ cd /home/source-android_4.1.1_r4

  $ repo init -u https://android.googlesource.com/platform/manifest -b android-4.1.1_r4

4.下载android-4.1.1_r4 源码

    $ cd /home/source-android_4.1.1_r4

    $ repo sync

四、常碰到的问题

1.代码下载过程中经常会有如下提示:

error: Failed connect to android.googlesource.com:443;Connection refused while accessinghttps://android.googlesource.com/a/platform/frameworks/base/info/refs

fatal: HTTP request failed

error: Cannot fetch platform/tools/motodev

error: Cannot fetch platform/frameworks/base

error: Cannot fetch platform/prebuilts/sdk

error: Exited sync due to fetch errors

解决方法:编辑/etc/hosts文件

$ vim /etc/hosts

增加下面内容,保存(提前保存好):

74.125.31.82 www.googlesource.com

74.125.31.82 android.googlesource.com

203.208.46.172 cache.pack.google.com

59.24.3.173cache.pack.google.com

然后重新输入

$ repo sync

2. git 版本过低的错误

fatal:git 1.7.2 or later required

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

原文地址:https://www.cnblogs.com/mizhongqin/p/android_4_1_1_r4_source.html