Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3082010
  • 博文数量: 94
  • 博客积分: 2599
  • 博客等级: 少校
  • 技术积分: 990
  • 用 户 组: 普通用户
  • 注册时间: 2006-08-30 23:23
文章分类

全部博文(94)

文章存档

2012年(1)

2011年(7)

2010年(24)

2009年(61)

2008年(1)

我的朋友

分类: LINUX

2009-12-08 23:53:46

This document describes how to set up your local workenvironment, how to use Repo to get the Android files, and how to buildthe files on your machine. & P1 T) Q6 n5 X# b3 @& A& O; [

% d0 D1 [+ O# o# N8 ]Related reading:. R& S+ v/ |0 \' u+ h
+ }/ d: _/ a2 C( r# F1 g2 G
  • For an overview of the entire code-review and code-update process, see .
  • For reference details about Repo, see .
What's in the source? For a description of all the projects that make up the Android source code, see . To see snapshots and histories of the files available in the public Android repositories, visit the web interface.
, d: ~3 _5 l6 w# }4 c% o, _! l" A0 F- G0 f/ e% Y
The source is approximentely 2.1GB in size.  You will need 6GB free to complete the build.
# C" d+ H0 ^7 o) u, ~
( a- r% o) D- l8 U( v8 P
$ I4 q& A/ ~( x% g) _! n4 R( p, zSetting up your machineTo build the Android source files, you will need to use Linux or Mac OS. Building under Windows is not currently supported. ! G7 M0 m% B; R
' T; R+ i( Z3 C, r: C) J
Linux To build the Android source under Linux, you will need Ubuntu. TheAndroid build is routinely tested on recent versions of Ubuntu (6.06and later), but reports of successes or failures on other distributionsare welcome. 8 x( o; q! M% M1 _- @

! M6 E+ _& }6 T" E' K5 VTo set up your Linux development environment, make sure you have the following:5 s4 o) x( N1 x  E! Q8 n2 A% q& E$ t" b

) E( c& i( j! F0 ]7 P7 m; _, }: B8 N
  • Git 1.5.4 or newer. Instructions for how to install and configure Git are below.
  • Python 2.4, which you can .
  • JDK 5.0, update 12 or higher, which you can .
  • The following packages: flex,bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional),build-essential. To make sure you have all these packages, run- l5 q& X" w) n) J9 }
       $ sudo apt-get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip
  • Youmight also want Valgrind, a tool that will help you find memory leaks,stack corruption, array bounds overflows, etc. To install it, run, Z5 S: s# T+ F6 R" W% |
       $ sudo apt-get install valgrind
    + T  p$ u# Y. e; q

8 ?$ V+ U& T+ ^) jMac OS) ~# \  a4 n# z3 Z+ `; v* h0 e% P$ X
9 Z; {' ]1 y( ^2 a2 }
Requirements:/ i( {, H6 R; |( p( P/ I+ J
  • To build the Androidfiles in a Mac OS environment, you need an Intel/x86 machine. TheAndroid build system and tools do not support the obsolete PowerPCarchitecture.
  • We recommend that you build Android on a partition that has been formatted with the "Case-sensitive Journaled HFS+" file system:
    • A case-sensitive file system is required because the sources contain files that differ only in case.
    • Journaled systems are more robust. (This is optional, but recommended.)
    • HFS+ is required to successfully build Mac OS applications such as the Android Emulator for OS X.
To set up your Mac OS development environment, follow these steps:* M( p) Z  |1 b6 ]' G* N" B5 U
  • Install the XCode version 2.4 or later from http://developer.apple.com . We recommend version 3.0 or newer.
  • Install MacPorts. To do this:
    • Download the tar file from and untar the files.
    • Run the following:
        u! F2 e8 J" r8 X8 R3 x+ t) K  $ ./configure  u% X! t7 Y* O+ j  P2 r1 T2 h. @
        
      $ make1 r0 q8 p. W  x, t- Y
        
      $ sudo make install
      - X! W2 Z! i4 k& ]  
      $ sudo port selfupdate
    • View your path:
      % c: x6 i+ d! R5 J4 q- Q9 R6 p! }7 N9 T% i' U: ^6 ^, f, I
      $ echo $PATH
      9 H, ?, K5 n; {Make sure that /opt/local/bin is in your path before /usr/bin. If not, edit $HOME/.bash_profile and add the line "export PATH=/opt/local/binPATH" (or the equivalent for other shells) after any other PATH-related lines. To verify that your path is now correct, open a new terminal and run echo $PATH again.
  • Upgrade GNU make to 3.81 or later by running7 E% q% b0 u5 I
      $ sudo port install gmake1 p+ z5 h8 J1 r# o
      $ sudo ln -s gmake /opt/local/bin/make
  • Install libsdl by running
    6 j5 @3 ?5 J/ @+ E5 \6 M  $ sudo port install libsdl
  • Set an appropriate per-process file descriptor limit. To do this, add the following lines to your .bash_profile file:
    . J( d2 e# {% C4 p4 U   # set the number of open files to be 1024
    $ l. D7 D3 h2 N: o: k  q5 z   ulimit -S -n 1024
  • Install these optional packages, if you want to:
    / p/ S# O4 b6 A* L1 U+ L   $ sudo port install xemacs +sumo
      w) u& d3 `8 @; n( i+ K   $ sudo port install gimp
Note: If you get errors from port install, prefix your commands with POSIXLY_CORRECT=1, for example:( G* O% h* k8 o+ s3 y# I
  $ POSIXLY_CORRECT=1 sudo port install package-name
3 t* [  n$ Q# N1 Z! g! o! Q
9 l. Z1 D" ~) s+ L- @3 O

+ z& V9 \3 v, w& y# j
8 K* O- C- t% s  }: a
% p; n% J" |; \5 QInstalling GitTo work with the Androidsource files, you will need to use the Git open-source version controlsystem and several complementary tools: 9 F# ^( S' d/ N2 d3 Z$ b

* r3 \0 x' y/ A) u' n$ |, B) e4 }
  • is a wrapper script that makes it easier to work with Git in the context of Android.
  • Gerrit is a visual interface for tracking, commenting on, and approving changes to the code.
Repo and Gerrit currently require Git 1.5.4 or newer. To check which version of Git (if any) is in your path, run  git --version.
* l# b% N6 B# P; W
To install Git and set up your files for the installation of Repo, follow these steps:6 H' ^8 ~% x. S1 c) R9 K0 S1 U

2 \' Q9 S9 R+ I3 b
  • Make sure you have a ~/bin directory in your home directory, and check to be sure that this bin directory is in your path:
    8 C9 ]5 [$ ~) p- a+ j6 a  $ cd ~
    0 w9 D! y2 I: k7 h# U: {- ^
      $ mkdir bin
    " F! R  u0 p5 h# ?6 J  $ echo $PATH
    - [4 q+ ]: Z& M2 C, \
  • Install Git and the GNU Privacy Guard:
    : b  w& E% E  G) a1 B" G- For Linux, run
    sudo apt-get install git-core gnupg2 w7 c% r' h+ [# D4 b- d* K2 h
    - For Mac OS:
    • Run sudo port install gnupg
    • Download the latest Git from .
    • Untar the file, then cd into the Git directory.
    • Run make install.
/ h# v1 @: _/ [" V0 x( x
For more about installing and configuring Git, see the .
$ s6 G& }' x9 [# e5 ~' r0 R  Y' F) A( L2 u% u+ L3 t; J# r8 U9 R6 H

  g( T8 n1 b, M1 @; d/ k8 S% V% i6 V
Installing Repo! Y5 K/ G3 L8 n' j/ W
To install, initialize, and configure Repo, follow these steps:$ ^# K- B9 E7 O& u
. S+ b) E  q7 [# t
  • Download the repo script and make sure it is executable:0 D: V5 G1 R4 z: Z7 Z
    $ curl >~/bin/repo
    $ chmod a+x ~/bin/repo
  • Create an empty directory to hold your working files:
    5 s! x2 O5 D$ O  C5 p7 S$ mkdir mydroid
    / [' F. ^8 b1 K# H% d1 I% r' l$ 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:
    , I1 j! N  [$ x( y1 J8 p3 f$ repo init -u git://android.kernel.org/platform/manifest.git
  • Whenprompted, configure Repo with your real name and email address. If youplan to submit code, use an email address that is associated with aGoogle account.
A successful initialization will end with a message such as/ t% r( @9 l7 d$ b+ y6 m2 Q
   repo initialized in /mydroid

# A2 N8 P: ~6 r7 S" J1 t, Z( d( e+ U; m3 L3 R3 P: H1 n1 [  @
Your client directory should now contain a .repo directory where files such as the manifest will be kept.
% M( k0 l$ u3 X

8 d8 _9 w% b  Y. n6 R
What will my name and email be used for?  
! C4 b; x# L0 O4 T% q1 a

; L# m+ F: z1 c  a5 F; q. nTo use the Gerrit code-review tool,
you will need an email address that is connected with a (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.

  e3 l& [5 Z  ]4 B$ t1 O- r
/ t0 J% z( {! s) I) QWhat is a manifest file?
* ]) _0 x0 I* M3 O2 C# b. X, YThe 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.
1 d8 r$ r9 {. r7 q+ Z
- [& f) Y# d8 S9 n9 Z  {4 L; d

  X- B  z" u9 c+ D/ _1 I
6 s" u& d( d7 [
Getting the files To pull down files to your working directory from the repositories as specified in the default manifest, run 1 B9 E# ?  [3 o) l0 z& Y+ Y3 }
0 m! v; b4 `- b% V* Y! {
   $ repo sync  
3 M5 ^  m1 l8 y  f( F! ?* b- \For more about repo sync and other Repo commands, see .9 L, B# B6 j& Y- M" Q* A2 h1 u
4 E% M. ]  e6 g4 P( P& Z% O& s
The Android source files will be located in your working directory under their names.

. _& j5 g; z$ S% S/ G) \* S
5 c2 ?% ~- b9 n  a* t8 f. m2 Q' L
Building the codeTo build the files, run make from within your working directory:6 R; f4 B8 c' y* }
    $ cd ~/mydroid  & M: ~' V& Y( k
    $ make
8 I2 \: g, V5 C4 `

  ~" Y& j4 r. P/ W$ c
What's next?To learn about reporting an issue and searching previously reported issues, see . For information about editing the files and uploading changes to the code-review server, see . ! Z5 t9 n2 x9 R& t, _1 w

安装ubuntu 8.04 server
) T* q' e3 _' X: t! X5 f! }修改添加源,我是采用清华ftp3
( O; d' S/ l  ]! f3 K" f5 m- [软件准备,sudo apt-get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential python valgrind curl git
+ ~9 w# \+ r5 j1 h$ cd ~
# K/ P( Z' N6 I1 ~$ mkdir bin
- r$ x- L  e# b6 d7 P1 h1 `$ _$ echo $PATH
8 g) f, u7 u3 N8 _! V6 Jpath中要求包含~/bin,默认是没有的,
2 j1 B9 X" R8 k, Evim ~/.bashrc* u' {$ Q9 S; K8 i5 k
export PATH=$PATH:~/bin' y' C+ m- S. ]
source ~/.bashrc
5 a  e* K5 D# I) ^" b! t# ^, cecho $PATH' M1 U8 b  s2 p
$ curl >~/bin/repo
3 o) g/ K" [/ T* J; c, |$ chmod a+x ~/bin/repo
0 U, E. o' n- o3 L
6 u6 K1 ]; s: `. |$ mkdir mydroid8 k+ v! X9 s0 ?0 u
$ cd mydroid
) f0 e5 T# G# q  U, H$ repo init -u git://android.kernel.org/platform/manifest.git. E0 j2 y0 y' ~* g5 q
$ repo sync
3 S$ G2 x5 n8 E" u' A$ cd ~/mydroid
/ q! a* b7 H) M; e0 z2 a$ a$ make
9 F) }& i& c5 L4 u) t其中遇到很多错误,解决方法如下:1 R) F' K/ q* v% }$ f( Y
external/tcpdump repo失败' l2 C/ M! x& _$ t) o0 t7 P/ ?
只能手动repo sync project-list, project-list参照0 V( E" G7 N% Q
注意其中有些project并不存在1 l# c; t  o% J, W
jdk-6-linux-i586.bin下载地址:* `) `; \  f$ P" b  i; C3 q7 y; B: {
安装方法:
- F4 X5 U" Y6 w# W9 ~5 P3 csh jdk-6-linux-i586.bin, and agree to the terms.
& I0 m) p: P, [, pexport JAVA_HOME=~/jdk1.6
, x' V9 n& n2 y- Z" ^3 R1 pexport HOME=$JAVA_HOME/binJAVA_HOME/jre/binPATH! r! ^% c( t: L" f, v4 L2 G& Y, t
make的时候报错,缺少external/wpa_supplicant,需要repo sync platform/external/wpa_supplicant
% |. t& w. D: G: n# H8 w  j缺少zlib.h,需要sudo apt-get install zlib1g-dev5 ?: T) ^( J+ g( l0 G: X3 @
源程序大约2G,共需要6G空间,如果内存小、机器慢,编译时间可能很长  d. o9 }5 ?$ d2 E) m
tcpdump和webkit等repo sync下载失败的问题,可以修改.repo/manifest.xml文件,将该项去除9 _+ U' l5 S4 F$ H# @! B
遇到com.google.com库不存在很错误,严重怀疑是repo sync不完整导致,解决方法为手工下载
5 l9 I: d  C" r/ F' m1 p3 s! e" L  _+ j, D5 T' k
然后将其打包如JAVA_LIBRARIES下的classes.jar中+ B* v6 X  P- L* M7 R: s7 M
另外把SDK中的class也全都打包到其中,避免编译出错$ K- C) `& j4 f
修改CLASSPATH环境变量,把SDK的class加入其中& T0 t, }* x" p' N% N* \
缺少ncurses库的问题,需要安装sudo apt-get install libncurses5-dev: a3 g6 B' X: h
缺少trace_common.h,需要下载qemu的source code,然后手工复制过去
5 h8 k* G" n8 I3 P4 p! y" }' \  I$ i
webkit的源程序也可以从此处下载得到,前面repo sync时候webkit失败
- F$ U* x5 G/ o4 |! Z  }7 G1 ?safe_iop.h失败的问题,需要下载safe_iop复制过去' ~- ~% D, F5 C( i* \" m& M3 q

* q# Q: d, g. j4 U6 _% \& _0 VNo rule to make target `out/host/linux-x86/bin/emulator', needed by `out/host/linux-x86/bin/dexpreopt.py'.大概是因为dexpreopt要求emulator程序已经安装,为了能继续编译,我在build/tools/dexpreopt下面的mk结尾文件改掉,暂时不编译该功能- w1 N9 j3 L: A' Q6 t
webkit的问题官方有了fix方案如下:
5 O, g+ l, F& T9 ^; brm -rf .repo/projects/external/webkit.git external/webkit
& T8 X) F; ~# @+ L: O2 G0 tcd .repo/manifests! v8 w: {- U5 n9 _: j; l
git pull
/ O- C6 p$ c  `4 i8 kcd ..! ~. Y( }+ x6 Q& H4 J; _. K% `
repo sync
阅读(3422) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~