- 论坛徽章:
- 0
|
Android
开源了,获取源代码祥见
http://source.android.com/download
我用的是Ubuntu Linux (i386),故步骤如下:
The Android build is routinely tested on recent versions of Ubuntu
(6.06 and later), but reports of successes or failures on other
distributions are welcome.
To set up your Linux development
environment, make sure you have the following:
Git
1.5.4 or newer. To
install Git and the GNU Privacy Guard, run
$
sudo
apt-get install git-core gnupg
JDK
5.0, update 12 or higher: run
$ sudo apt-get install
sun-java6-jdk
The following packages:
flex, bison, gperf, libsdl-dev,
libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl. To
make sure you have all these packages, run
$ sudo apt-get install flex
bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev
build-essential zip curl libncurses5-dev
You might also want Valgrind, a
tool that will help you find memory leaks, stack corruption, array
bounds overflows, etc. To install it, run
$ sudo apt-get install
valgrind
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 Using Repo and
Git.
To install, initialize, and configure Repo, follow these
steps:
Make sure you have a
~/bin directory
in your home directory, and check to be sure that this bin directory is
in your path:
$ cd ~
$ mkdir bin
$ echo $PATH
Download the repo script and make
sure it is executable:$ curl
http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x
~/bin/repo
Create an empty directory to hold
your working files:
$ mkdir
mydroid$ cd mydroid
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:
$ repo
init -u
git://android.git.kernel.org/platform/manifest.git
When prompted, configure Repo with
your real name and email address. If you plan to submit code, use an
email address that is associated with a Google account.
A successful initialization will end
with a message such as repo initialized in
/mydroid
Your client directory should now
contain a .repo directory
where files such as the manifest will be kept.
What will my name and email be
used for?
To
use the Gerrit code-review tool, you
will need an email address that is connected with a
registered Google account
(which
does not have to be a Gmail address). Make sure this is a
live address at which
you can receive messages. The real name that you provide here
will show up in attributions for your code
submissions.
What is a manifest file?
The
Android source files are divided among a number of different repositories.
A manifest file
contains a mapping of where the files from these repositories will be
placed within your working directory when you synchronize your files.
Getting the files
To pull down files to your working
directory from the repositories as specified in the default manifest, run
$ repo sync
For more about repo sync and other Repo
commands, see Using Repo and
Git.
The Android source files will be
located in your working directory under their
project
names.
Building the codeTo build the files, run make from within your
working directory:
$ cd
~/mydroid
$ make
If your build fails, complaining about a missing "run-java-tool", try
setting the ANDROID_JAVA_HOME env var to $JAVA_HOME before making.
E.g.,
$ export
ANDROID_JAVA_HOME=$JAVA_HOME
What's next?To
learn about reporting an issue and searching previously reported issues,
see
Report bugs
. For
information about editing the files and uploading changes to the
code-review server, see
Contribute
.
其中repo sync这一步经常出错。不停地重试才行。估计是取源码的人太多了,服务器受不了了。
网上一位牛人写了个脚本。以下为摘抄:
不幸的是不断发生fatal和error,不停地重试才行。在N次重试以后,到了这个组件时就不停地失败,platform/external/icu4c。我也手动试地累死了,于是写了个shell脚本,让系统在失败时睡眠三秒然后重试:
#!/bin/bash
echo "======start repo sync======"
repo sync
while [ $? = 1 ]; do
echo “======sync failed, re-sync again======”
sleep 3
repo sync
done
这段脚本很简单,首先先执行repo sync,如果失败了,就会发出错误退出信号1,由while捕获,判断如果是错误退出就继续,否则完成。主要就是“$?”这个变量,是由上一个执行完的命令返回的退出状态。
开始执行这段脚本,然后睡了个美美的午觉。
睡醒后一看,终于过去了,不过还没好。Android的组件真是多啊!一些组件如libxml2、libpng、dbus、sqlite真是熟悉啊,Android就是一个集众所之长的平台。
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/66024/showart_1411492.html |
|