---
title: "ubuntu12.04下载Android源代码"
author: "rafale35"
date: "2012-12-22T22:59:38Z"
tags: []
categories: ["操作系统"]
slug: "ubuntu12-04-android"
draft: false
lastmod: "2012-12-22T22:59:38Z"
id: 1752487
url: "https://rafale35.iteye.com/blog/1752487"
---

参考：http://source.android.com/source/initializing.html

 

## Installing required packages (Ubuntu 12.04)

Building on Ubuntu 12.04 is currently only experimentally supported and is not guaranteed to work on branches other than master.

 

```
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
  libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
```

 

准备完毕后，开始真正的下载工作了

 

# Downloading the Source Tree

## Installing Repo

Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see [Version Control](http://source.android.com/source/version-control.html) .

To install, initialize, and configure Repo, follow these steps:

 

```
$ mkdir ~/bin
$ PATH=~/bin:$PATH

```

 

Download the Repo script and ensure it is executable:

 

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

 

然而，实际下载确因总总原因无法下载

 

网上有好心人准备地址：

 

```
curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > ~/bin/repo
```

 

 

然后下面步骤，就是准备你下载的目录

```
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY

```

 

Run `repo init` to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.

 

 

```
$ repo init -u https://android.googlesource.com/platform/manifest

```

 

To check out a branch other than "master", specify it with -b:

 

```
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
```

 

然后执行：却出错

 

fatal: '../platform/abi/cpp.git' does not appear to be a git repository  
fatal: The remote end hung up unexpectedly  
error: Cannot fetch platform/abi/cpp

 

解决方法：

 

在.repo目录下的manifest.xml里找到fetch属性  
改成  
fetch= "git://Android.git.linaro.org/"

 

然后就可以下载了...耐心等待把...中间可能会被报错停止掉,重新repo sync 就可以了