To build the Android source under Linux, you will need Ubuntu. 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. Instructions for how to install and configure Git are below.
  • Python 2.4, which you candownload from python.org.
  • JDK 5.0, update 12 or higher, which you candownload from java.sun.com.
  • 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
    $ sudo apt-get install flex bison gperflibsdl-dev libesd0-devlibwxgtk2.6-dev build-essential
  • 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

Mac OS

Requirements:

  • To build the Android files in a Mac OS environment, you need an Intel/x86 machine. The Android build system and tools do not support the obsolete PowerPC architecture.
  • 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.
Toset up your Mac OS development environment, follow these steps:
  1. Install the XCode version 2.4 or later fromhttp://developer.apple.com. We recommend version 3.0 or newer.
  2. Install MacPorts. To do this:
    1. Download the tar file fromhttp://www.macports.org/and untar the files.
    2. Run the following:
      $ ./configure
      $make
      $sudo make install
      $sudo port selfupdate
    3. View your path:
      $echo $PATH
      Make sure that/opt/local/binis in your path before/usr/bin. If not, edit$HOME/.bash_profileand add the line "export PATH=/opt/local/bin:$PATH" (or the equivalent for other shells) after any other PATH-related lines.To verify that your path is now correct, open a new terminal andrunecho $PATHagain.
  3. Upgrade GNU make to 3.81 or later by running
    $ sudo port install gmake
    $ sudo ln -s gmake /opt/local/bin/make
  4. Install libsdl by running
    $ sudo port install libsdl
  5. Set an appropriate per-process file descriptor limit. To do this, add the following lines to your.bash_profilefile:
    # set the number of open files to be 1024
    ulimit -S -n 1024
  6. Install these optional packages, if you want to:
    $ sudo port install xemacs +sumo
    $ sudo port install gimp
Note: If you get errors fromport install, prefix your commands withPOSIXLY_CORRECT=1, for example:
$ POSIXLY_CORRECT=1 sudo port install package-name


Installing Git

To work with the Android source files, you will need to use the Git open-source version control system and several complementary tools:

  • Repois a wrapper script that makes it easier to work with Git in the context of Android.
  • Gerritis 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.

To install Git and set up your files for the installation of Repo, follow these steps:

  1. Make sure you have a~/bindirectory in your home directory, and check to be sure that this bin directory is in your path:
    $ cd~
    $ mkdir bin
    $ echo $PATH
  2. Install Git and the GNU Privacy Guard:
    - For Linux, run
    sudo apt-get install git-core gnupg
    - For Mac OS:
    1. Runsudo port install gnupg
    2. Download the latest Git fromhttp://git.or.cz/.
    3. Untar the file, then cd into the Git directory.
    4. Runmake install.
For more about installing and configuring Git, see theGit Community Book.

Installing Repo

To install, initialize, and configure Repo, follow these steps:
  1. Download thereposcript and make sure it is executable:
    $ curl http://android.kernel.org/repo >~/bin/repo
    $ chmod a+x ~/bin/repo
  2. Create an empty directory to hold your working files:
    $ mkdir mydroid
    $ cd mydroid
  3. Runrepo inittobring 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.kernel.org/platform/manifest.git
  4. 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.

What is a manifest file?

The Android source files are divided among a number of different repositories.A manifestfile contains a mapping of where the files from these repositories will be placed within your working directory when you synchronize your files.


A successful initialization will end with a message such as
repoinitialized in /mydroid


Your client directory should now contain a.repodirectory 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 aregistered Google account(which does not have to be a Gmail address). Make sure this isa live addressat which you can receive messages.The real name that you provide here will show up in attributions for your code submissions.

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 aboutrepo syncand other Repo commands, seeUsing Repo.

The Android source files will be located in your working directory under theirprojectnames.


Building the code

To build the files, runmakefrom within your working directory:
$ cd ~/mydroid
$ make

更多相关文章

  1. android 自动更新apk版本
  2. Android(安卓)sdk content loader 0% - mac
  3. 运行时改变Button的android:drawableTop
  4. Android(安卓)开源项目
  5. 第三课:android发送短信
  6. Android(安卓)获取路径目录方法
  7. 【063】◀▶ Android(安卓)(I) - 控件和布局
  8. android实现文本信息复制,剪切板(ClipboardManager)
  9. Android中通过资源文件获取drawable的几种方法

随机推荐

  1. Toolbar上overflow的样式自定义详解
  2. android中自动提示、补全、连接的功能实
  3. Android进阶(十九)AndroidAPP开发问题汇
  4. ros安装android
  5. Android(安卓)Duplicate files copied in
  6. 5 个顶级 Android(安卓)开源库
  7. 2010.12.16——— android listView 显示
  8. Android学习笔记SQLite
  9. 取消ScrollView滚动时的阴影
  10. Android(安卓)Push Notification Service