Get Android Source Code

Setup Build Machine

Host System

  • Google recommends recent versions of UBuntu (10.04 or newer)

Necessary Packages

  • Python 2.4 -- 2.7, which you can download from python.org
  • JDK 6 if you wish to build Gingerbread or newer. Lucid is the name for Ubuntu 10.04. Higher version of Ubuntu is compatible to use Lucid.

      $ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
      $ sudo apt-get update
      $ sudo apt-get install sun-java6-jdk

  • Git 1.7 or newer. You can find it at git-scm.com
  • GNU Make - Google recommends make 3.81
    note.gif GNU Make 3.82 will even prevent Android system from building
  • (Optional) Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc. Download from valgrind.org
  • Other 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
note.gif More information about this can be found in the official Android Page .

Add Environment Variables

  • Make sure you have a ~/bin directory in your home directory, and check to be sure that this bin directory is in your path
      $ mkdir ~/bin
      $ PATH=~/bin:$PATH
  • Add one line export PATH=~/bin:$PATH in file ~/.bashrc and
      $ source ~/.bashrc

Install 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, please follow the steps below:

  • Download the repo script and make sure it is executable
      $ cd ~
      $ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
      $ chmod a+x ~/bin/repo

Initialize Repo Repository

  • Create an empty folder < ANDROID_WORKING_DIR >. < ANDROID_WORKING_DIR > is the directory to download google source code. We use < ANDROID_WORKING_DIR > to denote the working path for Android building. For example, < ANDROID_WORKING_DIR > could be “~/mydroid”

      $ mkdir < ANDROID_WORKING_DIR >
      $ cd < ANDROID_WORKING_DIR >
  • 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:
      ~/mydroid $ repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.5_r1
      Get https://android.googlesource.com/tools/repo
      remote: Counting objects: 1462, done
      remote: Finding sources: 100% (80/80)
      Receiving objects: 100% (1462/1462), 437.79 KiB, done.
      remote: Total 1462 (delta 952), reused 1462 (delta 952)
      Resolving deltas: 100% (952/952), done.
      From https://android.googlesource.com/tools/repo
      * [new branch]      maint      -> origin/maint
      ................
      repo initialized in < ANDROID_WORKING_DIR >

Get Source Code

To pull down files to your working directory from the repositories as specified in the default manifest, run

 
      $ repo sync

ALERT!Note that this step may take quite a long time, depending on your connection speed. In case of any problem, run this command again.

See also: BuildAndroid, GenerateAndroidImage

r13 - 11 Jan 2012 - 07:02:48 - VoiceShen
 
Android4SAM

Copyright by the contributing authors. All material on the platform is the property of the contributing authors.

Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions

Atmel and others, are registered trademarks or trademarks of Atmel or its subsidiaries.This site is powered by the TWiki collaboration platform

ARM and others are registered trademarks or trademarks or ARM Ltd. Other terms and product names may be trademarks of others.

Under the terms of the Creative Commons Attribution License

Syndicate this siteRSS ATOM