Initializing a Build Environment
The "Getting Started" section describes how to set up your local work environment, how to use Repo to get the Android files, and how to build the files on your machine. To build the Android source files, you will need to use Linux or Mac OS. Building under
Windows is not currently supported.
Note: The source is approximately 2.6GB in size. You will need 10GB free to complete the build.
For an overview of the entire code-review and code-update process, see
Life of a Patch.
To see snapshots and histories of the files available in the public Android repositories, visit theGitWeb web interface.
Setting up a Linux build environment
The Android build is routinely tested in house on recent versions of Ubuntu (10.04 and later), but most distributions should have the required build tools available. Reports of successes or failures on other distributions are welcome.
Note: It is also possible to build Android in a virtual machine. If you are running Linux in a virtual machine, you will need at least 8GB of RAM/swap and 12GB or more of disk space in order to build the Android tree.
In general you will need:
-
Python 2.4 -- 2.7, which you can download from
python.org.
-
JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download both fromjava.sun.com.
-
Git 1.5.4 or newer. You can find it at git-scm.com.
-
(optional) Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc. Download fromvalgrind.org.
Detailed instructions for Ubuntu 10.04+ follow.
Installing the JDK
The Sun JDK is no longer in Ubuntu's main package repository. In order to download it, you need to add the appropriate repository and indicate to the system which JDK should be used.
Java 6: for Gingerbread and newer
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
Java 5: for Froyo and older
$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper main multiverse"
$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper-updates main multiverse"
$ sudo apt-get update
$ sudo apt-get install sun-java5-jdk
Installing required packages
To set up your development environment, install the following required packages:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos
Configuring USB Access
Under GNU/linux systems (and specifically under Ubuntu systems),regular users can't directly access USB devices by default. Thesystem needs to be configured to allow such access.
The recommended approach is to create a file/etc/udev/rules.d/51-android.rules
(as the root user) and to copythe following lines in it. must be replaced by theactual username of the user who is authorized to access the phonesover USB.
# adb protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>"
# fastboot protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>"
# adb protocol on crespo (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"
# fastboot protocol on crespo (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"
Those new rules take effect the next time a device is plugged in.It might therefore be necessary to unplug the device and plug itback into the computer.
This is known to work on both Ubuntu Hardy Heron (8.04.x LTS) andLucid Lynx (10.04.x LTS). Other versions of Ubuntu or othervariants of GNU/linux might require different configurations.
Setting up a Mac OS X build environment
To build the Android files in a Mac OS environment, you need an Intel/x86 machine running MacOS 10.4 (Tiger), 10.5 (Leopard), or 10.6 (Snow Leopard). The Android build system and tools do not support the obsolete PowerPC architecture.
Android must be built on a case-sensitive file system because the sources contain files that differ only in case. We recommend that you build Android on a partition that has been formatted with the journaled file system HFS+. HFS+ is required to successfully
build Mac OS applications such as the Android Emulator for OS X.
Creating a case sensitive disk image
If you want to avoid partitioning/formatting your hard drive, you can usea case-sensitive disk image instead. To create the image, launch DiskUtility and select "New Image". A size of 12GB is the minimum tocomplete the build, larger numbers are more future-proof.
Using sparse imagessaves space while allowing to grow later as the need arises. Be sure to select"case sensitive, journaled" as the volume format.
You can also create it from a shell with the following command:
# hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 40g ~/android.dmg
This will create a .dmg file which, once mounted, acts as a drive with the required formatting for Android development. For a disk image named "android.dmg" stored in your home directory, you can add the following to your~/.bash_profile
to mount
the image when you execute "mountAndroid":
# mount the android file image
function mountAndroid { hdiutil attach ~/android.dmg -mountpoint /Volumes/android; }
Once mounted, you'll do all your work in the "android" volume. You can eject it (unmount it) just like you would with an external drive.
Installing required packages
-
Install XCode from the Apple developer site. We recommend version 3.0 or newer. If you are not already registered as an Apple developer, you will have to create an Apple ID in order to download.
-
Install MacPorts from macports.org.
Note: Make sure that /opt/local/bin
appears in your path BEFORE/usr/bin
. If not, add
export PATH=/opt/local/bin:$PATH
to your ~/.bash_profile
.
-
Get make, git, and GPG packages from MacPorts:
$ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg
If using Mac OS 10.4, also install bison:
$ POSIXLY_CORRECT=1 sudo port install bison
Reverting from make 3.82
There is a bug in gmake 3.82 that prevents android from building. You can install version 3.81 using MacPorts by taking the following steps:
-
Edit /opt/local/etc/macports/sources.conf
and add a line that says
file:///Users/Shared/dports
above the rsync line. Then create this directory:
$ mkdir /Users/Shared/dports
-
In the new dports
directory, run
$ svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/
-
Create a port index for your new local repository:
$ portindex /Users/Shared/dports
-
Finally, install the old version of gmake with
$ sudo port install gmake @3.81
Setting a file descriptor limit
On MacOS the default limit on the number of simultaneous file descriptors open is too low and a highly parallel build process may exceed this limit.
To increase the cap, add the following lines to your ~/.bash_profile
:
# set the number of open files to be 1024
ulimit -S -n 1024
Next: Download the source
Your build environment is good to go! Proceed to
downloading the source....
分享到:
相关推荐
### Ubuntu 10.04下编译Android源码技术文档 #### 一、环境准备与配置 在Ubuntu 10.04环境下编译Android源码是一项复杂但极具价值的任务。为了确保编译过程顺利进行,首先需要完成一系列准备工作。 1. **系统更新...
在Ubuntu 10.04环境下,为了搭建Android的编译环境,我们需要完成一系列的步骤。这个过程主要包括安装Java Development Kit (JDK),配置相关的环境变量,安装必要的编译工具和依赖包,以及解决特定的系统问题。以下...
在Ubuntu 10.04环境下编译Android源码的过程是一项复杂的任务,涉及到多个步骤和技术。首先,要了解Git,这是一个分布式版本控制系统,由Linux Torvalds创建,用于管理Linux内核开发。与传统的集中式版本控制系统如...
### Ubuntu 10.04 下编译 Android 源码全过程详解 #### 一、获取 Android 源代码 **Git与集中式版本控制系统对比** - **Git**:由 Linux Torvalds 开发,是一种分布式版本控制系统。与 Subversion 和 CVS 这样的...
【Ubuntu 10.04下编译Android源码实用指南】 在Ubuntu 10.04系统中编译Android源码是一项复杂的过程,需要掌握Git版本控制系统以及Android的Repo工具。Git是Linux Torvalds为管理Linux内核开发而创建的分布式版本...
### Ubuntu环境下编译Android源码及安装的知识点详解 #### 实验环境介绍 - **操作系统**: Ubuntu 10.04 - **Android版本**: 2.1 - **开发板**: ARM9 Mini6410 - **目标**: 在Ubuntu环境下编译Android 2.1源码并进行...
标题 "Ubuntu 10.04 下 Deadbeef 完美支持源码" 提到的是在 Ubuntu 10.04 这个 Linux 发行版上安装和使用 Deadbeef 音乐播放器的源码编译方法。Deadbeef 是一款轻量级、高度可定制化的音频播放器,它支持多种音频...
通过上述步骤,你可以在Ubuntu 10.04上构建一个完整的Android开发环境,包括源码获取、构建环境搭建以及模拟器使用等关键环节。这对于初学者来说是一份非常宝贵的指南,帮助他们快速上手Android应用开发。
### Ubuntu 10.04 下编译 Android 源码全过程详解 #### 一、获取 Android 源代码 1. **Git 的介绍与安装**: - Git 是一种分布式版本控制系统,由 Linux Torvalds 为了更好地管理 Linux 内核开发而创建。 - **...
ubuntu10.04及12.04编译android环境搭建.txt
在Ubuntu 10.04操作系统中配置MTK6573的Android编译运行环境是一项复杂的任务,涉及到多个步骤和必要的组件安装。MTK6573是联发科(Mediatek)推出的一款针对智能手机和平板电脑的处理器,而Android则是运行在其上的...
Ubuntu_10.04上编译Android_2.3Ubuntu_10.04上编译Android_2.3
### Android 2.2 源码编译指南:Ubuntu 10.04 (X86) + Android 2.2 + JDK 1.6 #### 一、环境搭建 在进行Android 2.2源码编译之前,我们需要准备一个合适的开发环境。根据题目中的描述,本指南将详细介绍如何在...
### 在32位Ubuntu 10.04上编译Android 2.3的知识点 #### 一、环境准备 1. **安装JDK6**: - 对于Android 2.3系统的编译,应选择安装JDK6而不是JDK5。 - 在32位Ubuntu 10.04环境下,直接安装JDK6可能会导致编译时...
- 初始化源码仓库:在`software/android/src/new`目录下初始化Android源码仓库,指定分支为`froyo`。 - 同步源码:使用`repo sync`命令下载Android 2.2.1 (Froyo)的源码。 3. **源码编译**: - 开始编译:在源码...
### Ubuntu 10.04 下安装 OpenCV 2.2.0 详细步骤 #### 知识点一:Ubuntu 10.04 环境介绍 - **Ubuntu 10.04 LTS**(代号 Lucid Lynx)是 Ubuntu 的一个长期支持版本,发布于2010年4月29日。它提供了大量的软件包,...
安装Ubuntu 10.04 LTS完成后,接下来是一系列的初始化配置,主要包括: 1. 显示桌面图标:通过gconf-editor可以自定义桌面的图标显示,包括计算机、家庭和回收站等。 2. 更改用户权限:由于Ubuntu默认的安全性,...
在Ubuntu10.04下载和编译android 4.0源代码(三)