You are on page 1of 49


Android is an open-source software stack created for a wide array of devices with different form
factors. The primary purposes of Android are to create an open software platform available for
carriers, OEMs, and developers to make their innovative ideas a reality and to introduce a
successful, real-world product that improves the mobile experience for users. We also wanted to
make sure there was no central point of failure, where one industry player could restrict or
control the innovations of any other. The result is a full, production-quality consumer product
with source code open for customization and porting.
Android was originated by a group of companies known as the Open Handset Alliance, led by
Google. Today, many companies -- both original members of the OHA and others -- have
invested heavily in Android. These companies have allocated significant engineering resources to
improve Android and bring Android devices to market.
The companies that have invested in Android have done so on its merits because we believe an
open platform is necessary. Android is intentionally and explicitly an open-source -- as opposed
to a free software -- effort; a group of organizations with shared needs has pooled resources to
collaborate on a single implementation of a shared product. The Android philosophy is
pragmatic, first and foremost. The objective is a shared product that each contributor can tailor
and customize.
Uncontrolled customization can, of course, lead to incompatible implementations. To prevent
this, the Android Open Source Project also maintains the Android Compatibility Program, which
spells out what it means to be "Android compatible" and what is required of device builders to
achieve that status. Anyone can (and will!) use the Android source code for any purpose, and we
welcome all legitimate uses. However, in order to take part in the shared ecosystem of
applications we are building around Android, device builders must participate in the Android
Compatibility Program.
The Android Open Source Project is led by Google, who maintains and further develops
Android. Although Android consists of multiple subprojects, this is strictly a project management
technique. We view and manage Android as a single, holistic software product, not a
"distribution", specification, or collection of replaceable parts. Our intent is that device builders
port Android to a device; they don't implement a specification or curate a distribution.
To work with the Android code, you will need to use both Git and Repo. In most situations, you
can use Git instead of Repo, or mix Repo and Git commands to form complex commands. Using
Repo for basic across-network operations will make your work much simpler, however.
Git is an open-source version-control system designed to handle very large projects that are
distributed over multiple repositories. In the context of Android, we use Git for local operations
such as local branching, commits, diffs, and edits. One of the challenges in setting up the

Android project was figuring out how to best support the outside community--from the hobbiest
community to large OEMs building mass-market consumer devices. We wanted components to
be replaceable, and we wanted interesting components to be able to grow a life of their own
outside of Android. We first chose a distributed revision control system, then further narrowed it
down to Git.
Repo is a repository management tool that we built on top of Git. Repo unifies the many Git
repositories when necessary, does the uploads to our revision control system, and automates parts
of the Android development workflow. Repo is not meant to replace Git, only to make it easier to
work with Git in the context of Android. The repo command is an executable Python script that
you can put anywhere in your path. In working with the Android source files, you will use Repo
for across-network operations. For example, with a single Repo command you can download
files from multiple repositories into your local working directory.
Gerrit is a web-based code review system for projects that use git. Gerrit encourages more
centralized use of Git by allowing all authorized users to submit changes, which are
automatically merged if they pass code review. In addition, Gerrit makes reviewing easier by
displaying changes side by side in-browser and enabling inline comments.

The Android Open Source Project (AOSP) maintains a complete software stack to be ported by
OEMs and other device implementors and run on their own hardware. To maintain the quality of
Android, Google has contributed full-time engineers, product managers, user interface designers,
quality assurance testers, and all the other roles required to bring modern devices to market.
Accordingly, we maintain a number of "code lines" to clearly separate the current stable version
of Android from unstable experimental work. We roll the open source administration and
maintenance of the Android code lines into the larger product development cycle.
The chart below depicts at a conceptual level how AOSP manages code and releases. We're
referring to these as "code lines" instead of "branches" simply because at any given moment
there may be more than one branch for a given "code line". For instance, when a release is cut, it
may or may not become a new branch based on the needs of the moment.
1. At any given moment, there is a current latest release of the Android platform. This
typically takes the form of a branch in the tree.
2. Device builders and contributors work with the current latest release, fixing bugs,
launching new devices, experimenting with new features, and so on.
3. In parallel, Google works internally on the next version of the Android platform and
framework according to the product's needs and goals. We develop the next version of

Android by working with a device partner on a flagship device whose specifications are
chosen to push Android in the direction we believe it should go.
4. When the "n+1"th version is ready, it will be published to the public source tree and
become the new latest release.

1. A Linux or Mac system. It is also possible to build Android in a virtual machine on
unsupported systems such as Windows.
2. A 64-bit environment is required for Gingerbread (2.3.x) and newer versions, including
the master branch. You can compile older versions on 32-bit systems.
3. Python 2.6 -- 2.7, which you can download from
4. GNU Make 3.81 -- 3.82, which you can download from
5. Git 1.7 or newer. You can find it at
6. JDK 7 to build the master branch of Android in the Android Open Source

Project (AOSP); JDK 6 to build Gingerbread through KitKat; JDK 5 for Cupcake
through Froyo.

1. 30GB of free disk space to complete a single build and up to 100GB or more
for a full set of build.
2. 2GB RAM
3. Optical Mouse
4. Keyboard

Android is a mobile operating system (OS) based on the Linux kernel and currently developed
by Google. With a user interface based on direct manipulation, Android is designed primarily for
touchscreen mobile devices such as smartphones and tablet computers, with specialized user
interfaces for televisions (Android TV), cars (Android Auto), and wrist watches (Android Wear).
The OS uses touch inputs that loosely correspond to real-world actions, like swiping, tapping,
pinching, and reverse pinching to manipulate on-screen objects, and a virtual keyboard. Despite
being primarily designed for touchscreen input, it also has been used in game consoles, digital
cameras, regular PCs and other electronics.
Android's source code is released by Google under open source licenses, although most Android
devices ultimately ship with a combination of open source and proprietary software. Initially
developed by Android, Inc., which Google backed financially and later bought in 2005. Android
was unveiled in 2007 along with the founding of the Open Handset Alliance—a consortium of
hardware, software, and telecommunication companies devoted to advancing open standards for
mobile devices.
Android is popular with technology companies which require a ready-made, low-cost and
customizable operating system for high-tech devices. Android's open nature has encouraged a
large community of developers and enthusiasts to use the open-source code as a foundation for
community-driven projects, which add new features for advanced user or bring Android to
devices which were officially released running other operating systems. The operating system's
success has made it a target for patent litigation as part of the so-called "smartphone wars"
between technology companies.
The Java Development Kit (JDK) is an implementation of either one of the Java
SE, Java EE or Java ME platforms released by Oracle Corporation in the form of a
binary product aimed at Java developers on Solaris, Linux, Mac OS X or Windows.
The JDK includes a private JVM and a few other resources to finish the recipe to a
Java Application.[2] Since the introduction of the Java platform, it has been by far the
most widely used Software Development Kit (SDK). On 17 November 2006, Sun
announced that it would be released under the GNU General Public License (GPL),
thus making it free software. This happened in large part on 8 May 2007, when Sun
contributed the source code to the OpenJDK.

high-level programming language. The language provides constructs intended to enable clear programs on both a small and large scale. allowing Python code execution on a majority of systems. We first chose a distributed revision control system. Python code can be packaged into stand-alone executable programs for some of the most popular operating systems. Its design philosophy emphasizes code readability.PYTHON Python is a widely used general-purpose. GIT Git is an open-source version-control system designed to handle very large projects that are distributed over multiple repositories. In the context of Android. imperative and functional programming or procedural styles. including object-oriented. such as Py2exe or Pyinstaller. It features a dynamic type system and automatic memory management and has a large and comprehensive standard library. and edits. One of the challenges in setting up the Android project was figuring out how to best support the outside community--from the hobbiest community to large OEMs building mass-market consumer devices. then further narrowed it down to Git. Using third-party tools. commits. allowing for the distribution of Python-based software for use on those environments without requiring the installation of a Python interpreter. we use Git for local operations such as local branching. Python interpreters are available for installation on many operating systems. We wanted components to be replaceable. Python supports multiple programming paradigms. diffs. . and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C++ or Java. and we wanted interesting components to be able to grow a life of their own outside of Android.

The current rom made by the google is sometimes laggy and hangs sometimes.By using custom ROM we can make the os according to our use and make it fast and efficient.  Disable the volume warning that Android constantly shows when you increase the system volume while headphones are plugged in. always-present gateway to the Internet. . always-on.  Easily overclock your device to make it run faster or underclock it to make it run slower while squeezing out more battery life. using a more full-featured tablet interface for certain apps.SOFTWARE REQUIREMENT ANALYSIS Android's purpose is to establish an open platform for developers to build innovative apps. The Android SDK provides built-in tools that developers use to clearly state the device features their apps require. And Google Play shows apps only to those devices that can properly run them.The requirement of customising the source code is to have these features :  Install skins to customize how your entire Android operating system looks. That's why Android was designed as a robust platform for running aftermarket applications.  Run apps in tablet mode on a phone. We haven't met a user yet who didn't want to customize it by extending its functionality. A mobile phone is a highly personal. The Android Compatibility program defines the technical details of the Android platform and provides tools used by OEMs to ensure that developers' apps run on a variety of devices.  Hide the bottom navigation bar (on-screen buttons) to get more screen real estate.  Customize the quick settings menu Android includes to add your own most-used settings shortcuts.

10) 5. Note: The source download is approximately 8.04) 3. Configuring USB Access 6. Installing required packages (Ubuntu 12. Building under Windows is not currently supported. Branch 4.5GB in size. and up to 100GB (or more) for a full set of builds. Creating a case-sensitive disk image 2. Branch 4.2. Installing required packages (Ubuntu 10. You will need to use Linux or Mac OS. Installing required packages (Ubuntu 14. For an overview of the entire code-review and code-update process. Easily enable root access by toggling a system setting. Choosing a Branch 2. Setting up ccache 7. see Life of a Patch. Setting up a Mac OS X build environment 1. Next: Download the source This section describes how to set up your local work environment to build the Android source files.x and all earlier branches 4. . Using a separate output directory 3. Master branch 3. Initializing a Build Environment In this document 1. You will need over 30GB free to complete a single build.04) 4. Setting up a Linux build environment 1.x and earlier branches 4.04 -.0. Installing the JDK 2.11.

x) and newer versions. Note: It is also possible to build Android in a virtual machine. Once you have selected a branch. a 64-bit environment is required.Choosing a Branch Some of the requirements for your build environment are determined by which version of the source code you plan to compile. you will need at least 16GB of RAM/swap and 30GB or more of disk space in order to build the Android tree. Installing the JDK The master branch of Android in the Android Open Source Project (AOSP) requires Java 7. Setting up a Linux build environment These instructions apply to all branches. On Ubuntu. including master. follow the appropriate instructions below to set up your build environment. You may also choose to download and build the latest source code (called "master"). If you are running Linux in a virtual machine.3. including the master branch. The Android build is routinely tested in house on recent versions of Ubuntu LTS (12. See the Downloading and Building page for the list of hardware and software requirements. Java 7: For the latest version of Android $ sudo apt-get update $ sudo apt-get install openjdk-7-jdk Optionally. update the default Java version by running: . Reports of successes or failures on other distributions are welcome. See Build Numbers for a full listing of branches you may choose from. but most distributions should have the required build tools available. Then follow the detailed instructions for Ubuntu and MacOS below. in which case you will simply omit the branch specification when you initialize the repository. Older versions can be compiled on 32-bit systems. use OpenJDK. For Gingerbread (2.04).

10: $ sudo ln -s /usr/lib32/mesa/libGL. $ 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 python-markdown \ libxml2-utils xsltproc On Ubuntu 10. Building using an older version of Ubuntu is not supported on master or recent releases. To develop older versions of Installing required packages (Ubuntu 14.10) Building on Ubuntu 10. $ sudo apt-get install git gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \ libgl1-mesa-dev g++-multilib mingw32 tofrodos \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386 $ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.10 is no longer supported. Installing required packages (Ubuntu 12.1 /usr/lib/i386-linuxgnu/ $ sudo apt-get install bison g++-multilib git gperf libxml2-utils Installing required packages (Ubuntu 10. Ubuntu /usr/lib32/mesa/libGL.$ sudo update-alternatives --config java $ sudo update-alternatives --config javac If you encounter version errors for Java.11.10: $ sudo apt-get install libx11-dev:i386 . but may be useful for building older releases of AOSP.04) You will need a 64-bit version of Ubuntu.04 -.04 is experimental at the moment but will eventually become the recommended environment. set its path as described in the Wrong Java Version section.04 is recommended.04-11. download and install the corresponding version of the Java JDK: Java 6: for Gingerbread through KitKat Java 5: for Cupcake through Froyo Note: The lunch command in the build step will ensure that the Sun JDK is used instead of any previously installed JDK.04) Building on Ubuntu On Ubuntu 11.

OWNER="<username>" # adb protocol on maguro/toro (Galaxy Nexus) SUBSYSTEM=="usb". OWNER="<username>" # fastboot protocol on grouper/tilapia (Nexus 7) SUBSYSTEM=="usb". ATTR{idVendor}=="04e8". OWNER="<username>" # fastboot protocol on stingray/wingray (Xoom) SUBSYSTEM=="usb". MODE="0600".Configuring USB Access Under GNU/linux systems (and specifically under Ubuntu systems). ATTR{idVendor}=="18d1". MODE="0600". MODE="0600". ATTR{idProduct}=="4e30". ATTR{idVendor}=="22b8". ATTR{idProduct}=="70a9". ATTR{idProduct}=="4e40". ATTR{idProduct}=="d002". ATTR{idProduct}=="4e20". OWNER="<username>" # adb protocol on manta (Nexus 10) . MODE="0600". MODE="0600". ATTR{idVendor}=="18d1". OWNER="<username>" # adb protocol on stingray/wingray (Xoom) SUBSYSTEM=="usb". OWNER="<username>" # fastboot protocol on crespo/crespo4g (Nexus S) SUBSYSTEM=="usb". MODE="0600". ATTR{idVendor}=="18d1". ATTR{idVendor}=="0451".d/51-android. ATTR{idProduct}=="d00f". MODE="0600". ATTR{idVendor}=="18d1". MODE="0600". MODE="0600". ATTR{idProduct}=="708c". OWNER="<username>" # adb protocol on panda (PandaBoard) SUBSYSTEM=="usb". ATTR{idProduct}=="4e22". ATTR{idVendor}=="0451". OWNER="<username>" # fastboot protocol on panda (PandaBoard) SUBSYSTEM=="usb". OWNER="<username>" # fastboot protocol on maguro/toro (Galaxy Nexus) SUBSYSTEM=="usb". MODE="0600". ATTR{idVendor}=="18d1". MODE="0600". <username> must be replaced by the actual username of the user who is authorized to access the phones over USB. ATTR{idProduct}=="6860".rules (as the root user) and to copy the following lines in it. # adb protocol on passion (Nexus One) SUBSYSTEM=="usb". MODE="0600". OWNER="<username>" # fastboot protocol on passion (Nexus One) SUBSYSTEM=="usb". regular users can't directly access USB devices by default. OWNER="<username>" # adb protocol on grouper/tilapia (Nexus 7) SUBSYSTEM=="usb". ATTR{idProduct}=="4e12". ATTR{idProduct}=="4e42". OWNER="<username>" # adb protocol on panda (PandaBoard ES) SUBSYSTEM=="usb". ATTR{idVendor}=="18d1". ATTR{idVendor}=="0451". OWNER="<username>" # usbboot protocol on panda (PandaBoard) SUBSYSTEM=="usb". ATTR{idVendor}=="18d1". ATTR{idProduct}=="d010". ATTR{idProduct}=="d022". The system needs to be configured to allow such access. ATTR{idVendor}=="0bb4". OWNER="<username>" # usbboot protocol on panda (PandaBoard ES) SUBSYSTEM=="usb". MODE="0600". ATTR{idProduct}=="0fff". The recommended approach is to create a file /etc/udev/rules. OWNER="<username>" # adb protocol on crespo/crespo4g (Nexus S) SUBSYSTEM=="usb". MODE="0600". ATTR{idVendor}=="18d1". MODE="0600". ATTR{idVendor}=="0451". ATTR{idProduct}=="d101".

MODE="0600". Other versions of Ubuntu or other variants of GNU/linux might require different configurations. If your home directory is on NFS or some other non-local filesystem. builds are faster when storing the source files and the output on separate volumes.x LTS) and Lucid Lynx (10.04. For additional performance. since all files can be re-generated in case of filesystem corruption.bashrc as well. export the OUT_DIR_COMMON_BASE variable to point to the location where your output directories will be stored. the output can be stored on a filesystem optimized for speed instead of crash robustness. ATTR{idVendor}=="18d1". the output of each build is stored in the out/ subdirectory of the matching source tree.04.x) or older. This is known to work on both Ubuntu Hardy Heron (8.bashrc or equivalent. OWNER="<username>" Those new rules take effect the next time a device is plugged in. or if you frequently switch between different build products. Ccache acts as a compiler cache that can be used to speed-up rebuilds. export CCACHE_DIR=<path-to-your-cache-directory> The suggested cache size is 50-100GB. On some machines with multiple storage devices. export OUT_DIR_COMMON_BASE=<path-to-your-out-directory> . It might therefore be necessary to unplug the device and plug it back into the computer. ATTR{idProduct}=="4ee0".ccache. Setting up ccache You can optionally tell the build to use the ccache compilation tool. MODE="0600". You will need to run the following command once you have downloaded the source code: prebuilts/misc/linux-x86/ccache/ccache -M 50G When building Ice Cream Sandwich (4.x LTS). ATTR{idVendor}=="18d1". ccache is in a different location: prebuilt/linux-x86/ccache/ccache -M 50G This setting is stored in the CCACHE_DIR and is persistent.0. Put the following in your . To set this up. you will want to specify the directory in your . This works very well if you do "make clean" often. ATTR{idProduct}=="4ee2". export USE_CCACHE=1 By default the cache will be stored in ~/.SUBSYSTEM=="usb". Using a separate output directory By default. OWNER="<username>" # fastboot protocol on manta (Nexus 10) SUBSYSTEM=="usb".

acts as a drive with the required formatting for Android development. 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 . building the master branch in a modern OS X environment is very straightforward. For a disk image named "android. A size of 25GB is the minimum to complete the build.dmg (or possibly a . discussed below. This can be done fairly easily using a disk image. with unpredictable results. Earlier branches. Be sure to select "case sensitive. launch Disk Utility and select "New Image".The output directory for each separate source tree will be named after the directory holding the source tree.sparsefile) file which. journaled" as the volume format. Because of this. Setting up a Mac OS X build environment In a default installation.bash_profile to mount the image when you execute "mountAndroid": . For instance. This is only supported on Jelly Bean (4. we recommend that you always work with the AOSP source files on a case-sensitive filesystem.dmg. This type of filesystem is not supported by git and will cause some git commands (such as "git status") to behave abnormally. It's important in that case to not have multiple source trees stored in directories that have the same name. if you have source trees as /source/master1 and /source/master2 and OUT_DIR_COMMON_BASE is set to /output. once mounted. the output directories will be /output/master1 and /output/master2. To create the image. Using sparse images saves space while allowing to grow later as the need arises.dmg" stored in your home directory. Creating a case-sensitive disk image You can create a case-sensitive filesystem within your existing OS X environment using a disk image. as those would end up sharing an output directory. including the master branch.1) and newer. you can add the following to your ~/. OS X runs on a case-preserving but case-insensitive filesystem. larger numbers are more future-proof. including ICS. require some additional tools and SDKs. Once the proper filesystem is available.

x could cause difficulties.2.x and earlier source in a Mac OS environment. Branch 4.8 (Mountain Lion).dmg To develop for versions of Android Gingerbread through (Leopard) or MacOS 10. Select the file: jdk-7u51-macosx-x64.dmg -mountpoint /Volumes/android.2 and Command Line Tools. you will have to create an Apple ID in order to download. you will need an Intel/x86 machine running MacOS 10. You can eject it (unmount it) just like you would with an external drive.2 (Apple's Developer Tools). add export PATH=/opt/local/bin:$PATH to your ~/.5. You will also need the Java 7 JDK. you will need an Intel/x86 machine running MacOS 10. git. Although Lion does not come with a JDK.bash_profile. If not. you'll do all your work in the "android" volume. along with Xcode 4.2.6 (Snow Leopard).6 (Snow Leopard) or MacOS 10. Branch 4.0. We recommend version 3. i. it should install automatically when you attempt to build the source. along with Xcode 4.4 or newer.  Get make.5 SDK. Installing required packages  Install Xcode from the Apple developer site.  Install MacPorts from macports.e. Master branch To build the latest source in a Mac OS environment.x and all earlier branches To build android-4. gcc 4. Version 4.0.1. and GPG packages from MacPorts: . Note: Make sure that /opt/local/bin appears in your path BEFORE /usr/bin. You will need the MacOS 10.x and earlier branches in a Mac OS environment. download and install the Java 6 version of the Java JDK.x and earlier branches To build 4.2. The remaining sections for Mac OS X only apply to those who wish to build earlier branches. you need an Intel/x86 machine running MacOS 10.# mount the android file image function mountAndroid { hdiutil attach ~/android.7 (Lion). } Once mounted. If you are not already registered as an Apple developer.

add the following lines to your ~/.conf and add a line that says file:///Users/Shared/dports above the rsync line. run $ svn co --revision 50980 http://svn.$ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg If using Mac OS 10. You can install version 3. also install bison: $ POSIXLY_CORRECT=1 sudo port install bison Reverting from make 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.bash_profile: # set the number of open files to be 1024 ulimit -S -n 1024 .82 that prevents android from devel/gmake/  Create a port index for your new local repository: $ portindex /Users/Shared/dports  Finally. Then create this directory:  $ mkdir /Users/Shared/dports In the new dports directory. install the old version of gmake with $ sudo port install gmake @3. there is a bug in gmake 3.macports.82 For versions of Android before ICS.4. To increase the cap.81 using MacPorts by taking the following steps:  Edit /opt/local/etc/macports/sources.



In addition. In the context of Android. The repo command is an executable Python script that you can put anywhere in your path. and we wanted interesting components to be able to grow a life of their own outside of Android. In working with the Android source files. Gerrit makes reviewing easier by displaying changes side by side in-browser and enabling inline comments. Git is an open-source version-control system designed to handle very large projects that are distributed over multiple repositories. only to make it easier to work with Git in the context of Android. Gerrit is a web-based code review system for projects that use git. and edits. Basic Workflow . diffs. however. you will need to use both Git and Repo. commits. Repo is not meant to replace Git.CLASS DIAGRAMS To work with the Android code. you can use Git instead of Repo. We first chose a distributed revision control system. you will use Repo for across-network operations. which are automatically merged if they pass code review. One of the challenges in setting up the Android project was figuring out how to best support the outside community--from the hobbiest community to large OEMs building mass-market consumer devices. or mix Repo and Git commands to form complex commands. We wanted components to be replaceable. with a single Repo command you can download files from multiple repositories into your local working directory. Repo is a repository management tool that we built on top of Git. Gerrit encourages more centralized use of Git by allowing all authorized users to submit changes. For example. Repo unifies the many Git repositories when necessary. we use Git for local operations such as local branching. does the uploads to our revision control system. Using Repo for basic across-network operations will make your work much simpler. In most situations. and automates parts of the Android development workflow. then further narrowed it down to Git.

3. Use repo start to start a new topic branch. Use repo upload to upload changes to the review server. 4.. Edit the files. For information about using repo to download source. 2. Task reference The task list below shows a summary of how to do common Repo and Git tasks. A topic branch is not a copy of the original files. it is a pointer to a particular commit. Use git add to stage changes. see Downloading the Source and Using Repo.The basic pattern of interacting with the repositories is as follows: 1. 5.. for example when you begin work on a bug or new feature. Use git commit to commit changes. Synchronizing your client To synchronize the files for all available projects: $ repo sync To synchronize the files for selected projects: $ repo sync PROJECT0 PROJECT1 PROJECT2 . Creating topic branches Start a topic branch in your local work environment whenever you begin a change. This makes creating local branches and switching among .

You can stage your changes by running git add . navigate into the project to be modified and issue: $ repo start BRANCH_NAME . the period represents the project in the current working directory. For an interesting article about using topic branches. This is also called "staging". Staging files By default. To verify your new branch was created: $ repo status . then run git checkout again. see Separating topic branches. Git notices but does not track the changes you make in a project. In order to tell git to preserve your changes. Using topic branches To assign the branch to a particular project: $ repo start BRANCH_NAME PROJECT_NAME To switch to another branch that you have created in your local work environment: $ git checkout BRANCH_NAME To see a list of existing branches: $ git branch or $ repo branches The name of the current branch will be preceded by an asterisk. you must mark them for inclusion in a commit. To start a topic branch using Repo.them a light-weight operation. By using branches. you can isolate one aspect of your work from the others. If git branch shows * (no branch) after you run repo sync. Note: A bug might be causing repo sync to reset the local topic branch. Please note.

Despite the name. update to the latest revisions: repo sync Next run repo upload . if you were to commit right now. it can also be used to stage file modifications and deletions. be sure you are in the project directory: $ cd ~/WORKING_DIRECTORY/PROJECT $ git diff --cached Committing changes A commit is the basic unit of revision control in git. please provide a helpful message for any changes you submit to the AOSP. If you do not add a log message. Uploading changes to Gerrit Before uploading.which accepts as arguments any files or directories within the project directory. git add does not simply add files to the git repository. Viewing client status To list the state of your files: $ repo status To see uncommitted edits: $ repo diff The repo diff command shows every local edit that you have made that would not go into the commit. git diff. Before running it. you need a Git command. consisting of a snapshot of directory structure and file contents for the entire project. the commit will be aborted. To see every edit that would go into the commit if you were to commit right now. Creating a commit in git is as simple as typing git commit You will be prompted for a commit message in your favorite editor.

PROJECTN Cleaning up your client files To update your local working directory after changes are merged in Gerrit: $ repo sync To safely remove stale topic branches: $ repo prune Deleting a client Because all state information is stored in your client. For example: $ git add .. $ git commit $ git rebase --continue  When the rebase is complete start the entire sync again: $ repo sync PROJECT0 PROJECT1 . you will see a simple y/n prompt. If there is only one branch. . Recovering sync conflicts If a repo sync shows sync conflicts:  View the files that are unmerged (status code = U).. you only need to delete the directory from your filesystem: $ rm -rf WORKING_DIRECTORY Deleting a client will permanently delete any changes you have not yet uploaded for review. and then "rebase" the changes.This will list the changes you have committed and prompt you to select which branches to upload to the review server.  Edit the conflict regions as necessary. run git add and git commit for the files in question.  Change into the relevant project directory.



c LOCAL_MODULE_TAGS := eng development LOCAL_SHARED_LIBRARIES := cutils include $(BUILD_EXECUTABLE) (HOST_)EXECUTABLE. (HOST_)SHARED_LIBRARY. as necessary (LOCAL_MODULE_TAGS := eng development). JAVADOC. COPY_HEADERS. The following snippet illustrates a typical makefile. Before continuing.CODING Android Build System Android uses a custom build system to generate tools. If you don't have version 3. 3. Local Variables: Clear local variables with CLEAR_VARS ( include $ (CLEAR_VARS)). Files: Determine which files your application depends upon (LOCAL_SRC_FILES := main. (HOST_)JAVA_LIBRARY. LOCAL_PATH := $(my-dir) include $(CLEAR_VARS) LOCAL_MODULE := <buil_name> LOCAL_SRC_FILES := main. RAW_EXECUTABLE. Makefiles typically include all of the following elements: 1. 4. Android's build system is make based and requires a recent version of GNU Make (note that Android uses advanced features of GNU Make that may not yet appear on the GNU Make web site). Libraries: Define whether your application links with other libraries (LOCAL_SHARED_LIBRARIES := cutils). . Name: Give your build a name (LOCAL_MODULE := <build_name>). 6. check your version of make by running % make -v. Template file: Include a template file to define underlining make tools for a particular target (include $(BUILD_EXECUTABLE)). (HOST_)STATIC_LIBRARY. (HOST_)PREBUILT. Understanding the makefile A makefile defines how to build a particular application. Tags: Define tags. 2.80 or greater. RAW_STATIC_LIBRARY. This document provides an overview of Android's build system and instructions for doing a simple build.c). and documentation. PACKAGE. binaries. you need to upgrade your version of make. KEY_CHAR_MAP The snippet above includes artificial line breaks to maintain a print-friendly document. 5.

as described below. then you can begin to modify Android for your own target device. Devic myDevice.Layers The build hierarchy includes the abstraction layers described in the table below. % cd $TOP % . Layer Example Description Produ myProduct. Board sardine. Arch The arch layer describes the processor running on your board. Each layer relates to the one above it in a one-to-many relationship. goldfish The board layer represents the bare schematics of a product. You may still connect peripherals to the board layer. j2. The product layer defines a complete specification of a ct myProduct_eu. For example. an arch can have more than one board and each board can have more than one device. source build/envsetup. e myDevice_eu. 68k Building the Android Platform This section describes how to build the default version of # pick a configuration using choosecombo % choosecombo . Peripherals typically connect to the device layer. myDevice_eu_lite The device layer represents the physical layer of plastic on the device. Once you are comfortable with a generic build. You might offer a device in sdk several different versions based on locale. You may define an element in a given layer as a specialization of an element in the same layer. for example. For example. which contains necessary variable and function definitions. North American devices probably include QWERTY keyboards whereas devices sold in France probably include AZERTY keyboards. x86. or on features such as a camera. defining which modules to build and myProduct_eu_fr. build/envsetup. how to configure them. arm (arm5te) (arm6). shipping product. thus eliminating copying and simplifying maintenance. Device Code To do a generic build of android.

device Dex: core UNEXPECTED TOP-LEVEL ERROR: java.hashCode(FixedSizeList. ..5 or later and your receive this error.util.] dx is a Java program that uses facilities first made available in Java version 1.NoSuchMethodError: method java.hash( at java.FixedSizeList. Speeding Up Rebuilds The binaries of each combo are stored as distinct sub-directories of //out/.0_07-164) Java HotSpot(TM) Client VM (build at Cleaning Up Execute % m clean to clean up the binaries you just created.util. at com. Standard Edition (build 1. If this happens often..Rop. which reduces recompiling all sources. % m clobber is equivalent to removing the //out/ directory where all generated files are stored. verify that you have properly updated your PATH variable. However.lang.Arrays.hashCode with signature ([Ljava..rop.util. mixed mode.)I was not found.0_07" Java(TM) 2 Runtime Environment. and don't need to get installed on your system. you should define the USE_CCACHE environment variable as shown below: % export USE_CCACHE=1 Doing so will force the build system to use the ccache compiler cache tool.hashCode(Rop. You can also execute % m clobber to get rid of the binaries of all combos. sharing) If you do have Java 1. performing a clean rebuild is necessary if the build system doesn't catch changes to environment variables or makefiles.code.5.5. Troubleshooting The following error is likely caused by running an outdated version of Java.HashMap.7) [. ccache binaries are provided in //prebuilt/. You should see something like: java version " Check your version of Java by executing % java -version in the shell you use to build. making it possible to quickly switch between combos without having to recompile all sources each time.5.lang.% make -j4 PRODUCT-generic-user You can also replace user with eng for a debug engineering build: % make -j4 PRODUCT-generic-eng These Build Variants differ in terms of debug options and packages

execute: % make -j4 Build Variants When building for a particular % partner_setup generic Then switch to the kernel directory /home/joe/android/kernel. build/envsetup. switch to the device directory (/home/joe/android/device) in order to establish variables and run: % . give your local branch the same name as the remote branch it is tracking (as illustrated in the snippet above). Once you are comfortable with a generic build. Building the Kernel To build the kernel. To build the kernel base. Checking Out a Branch The default branch is always android. These are the currently-defined build variants: eng This is the default flavor. . then you can begin to modify Android drivers for your own target device. it's often useful to have minor variations on what is ultimately the final release build. To check out a different branch. A plain make is the same as make eng. execute the following: % git checkout --track -b android-mydevice origin/android-mydevice //Branch android-mydevice set up to track remote branch % refs/remotes/origin/android-mydevice. Switch between branches by executing % git checkout <branchname>. Verifying Location Find out which branches exist (both locally and remotely) and which one is active (marked with an asterisk) by executing the following: % git branch -a android * android-mydevice origin/HEAD origin/android origin/android-mydevice origin/android-mychipset To only see local branches.Building the Android Kernel This section describes how to build Android's default kernel. //Switched to a new branch "android-mydevice" To simplify code management. omit the -a flag.

android. debug. tags are ignored for APK modules.  ro. and/or development.debuggable=0  adb is disabled by default.  Installs non-APK modules that have no tags specified.checkjni=1  adb is enabled by default. user  Installs modules tagged with user. except: userdebug  Also installs modules tagged with debug.debuggable=1  adb is enabled by default. in addition to tagged APKs. .  Installs APKs according to the product definition files.  ro.  Installs APKs according to the product definition files. user. make userdebug The same as user. Installs modules tagged with: eng.debuggable=1    ro.  ro.kernel.  Installs non-APK modules that have no tags specified. make user This is the flavor intended to be the final release bits.

jpg file to .165.155.84/servlets/mms" /> . splashscreen.jpg in this example. Create a 320x480 image. Android displays a splashscreen image while booting the device.xml. 4. convert screen.voicestream. Using ImageMagick. 7.r 5.jpg screen. You should not modify this file.155.50" port="8080" mmsc="http://216. convert your . but instead configure APNs by product at build time (see Build-time APN Configuration below). Do the following if you wish to modify the default splash screen: 1. Use the rgb2565 application to convert the image to 565 format: 6. rgb2565 < screen.565 8. fastboot flash splash1 screen.565 Network Customization Platform Network Configuration Android stores network configurations as a resource that gets compiled into binary at form at build time. The XML representation of this resource is located at //android/frameworks/base/core/res/res/xml/apns.r format: 3.Customization Boot Screen Customization At startup.174. 2. 10.rgb >" user="none" server="*" password="none" proxy=" 216. Use fastboot to flash the image to the device: 9. Each network configuration is stored in an XML element following this syntax: <apn carrier="T-Mobile US" mcc="310" mnc="260" apn=" wap. This file does not include any configured APNs.

"Company Name US. To configure APNs at the product level. It will be possible to develop a network configuration service which listens to a specific binary SMS port for binary SMS messages containing the network configurations. etc. You can upgrade a resource at runtime by installing a new system resource APK package. binary SMS formats. input methods. services.). set PRODUCT_PACKAGES property in the product configuration. This allows multiple products. NOTE: The implementation will likely be network operator dependent due to inconsistent SMS ports.xml Android supports the following run-time network configuration methods to choose the appropriate APN from the list of configured APNs:  Automatic Configuration: At boot time. add a line to the product configuration file like the example below (vendor/<vendor_name>/products/myphone-us. add an apns-conf. providers. Customizing pre-loaded applications To customize the list of Android packages for a particular product (applications. to be built off the same code PRODUCT_COPY_FILES := vendor/acme/etc/apns-conf-us.xml file to the product configuration (do not modify the default platform APNs). etc.  WAP / SMS Push Configuration: The network configurations are standard Android resources.Build-time APN configuration To set the APN configuration for a particular product target.  Manual Configuration: The platform will also support runtime (user) manual selection of network settings by name. Android determines the correct network configuration based on the MCC and MNC from the SIM card and automatically configure all network settings. for example.xml:system/etc/apnsconf. all with different APNs." and will support manual network configuration entry. as illustrated below: PRODUCT_PACKAGES := \ <company_name>Mail \ <company_name>IM \ <company_name>HomeScreen \ <company_name>Maps \ <company_name>SystemUpdater . the Android reads APNs from the following file: system/etc/apns-conf.xml APN configuration at run time At runtime.

).com/</item> <item>Facebook</item> <item></item> <item>MSN</item> <item></item> <item>CNN</item> .mk Note that the home screen is just an Android application that can be replaced entirely or customized by changing source code and application resources (Java source. the could look like this: # Build the <company_name>Mail application LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := user development LOCAL_SRC_FILES := $(call all-java-files-under.src.facebook.xml.myspace.Bookmarks --> <string-array name="bookmarks"> <item>Google</item> <item>http://www. For example: <!-. Each bookmark entry is stored as a pair of array</item> <item>Yahoo!</item> <item>http://www.ebay. etc. the first represents the bookmark name and the second the bookmark</item> <item>MySpace</item> <item>http://www. For example. referenced</item> <item>Wikipedia</item> <item>http://www. Bookmarks are defined as simple value string arrays called "bookmarks".Package names should correspond to the LOCAL_PACKAGE_NAME specified for each package's build</item> <item>eBay</item> <item>http://www. layouts.tests) LOCAL_STATIC_JAVA_LIBRARIES := <company_name>login-client # Specify the package name LOCAL_PACKAGE_NAME := <company_name>Mail # Specify the certificate used to sign the application LOCAL_CERTIFICATE := vendor/<company_name>/certs/app include $(BUILD_PACKAGE) # Build the login client static library include $(LOCAL_PATH)/client/Android. Customizing browser bookmarks Browser bookmarks are stored as string resources in the Browser application: //android/packages/apps/Browser/res/values/ build target for <company_name>

com" username="$email"/> <outgoing uri="smtp+ssl+://smtp.Common US providers --> <provider id="aim" label="AIM" domain="aim.xml file and place it under a Mobile Network Code (MNO) specific resource folder. <providers> <!-. Browser/res/values-mccXXX-mncYYY/" username="$email"/> <outgoing uri="smtp+ssl+://smtp.xml where XXX and YYY represent the three-digit MCC and two to three digit MNC values. Android loads any configuration-specific resources as override values for the default values. the platform will load alternate resources based on the platform configuration<item>" username="$email"/> </provider> <!"> <incoming uri="imap+ssl+://</item> </string-array> Like and Android application">"> <incoming uri="imap+ssl+://imap. place your customized bookmarks in a separate strings. Email Provider Customization The default email provider settings are stored as string resources in the Email application (//android/packages/apps/Email/res/xml/providers. For</item> <item>New York Times</item> <item>" username="$email"/> <outgoing uri="smtp+ssl+://smtp. so it is only necessary to include the bookmarks string-array values in this</item> <item>ESPN</item> <item>http://espn. See Resources and Internationalization in the Android SDK for</item> <item>Weather Channel</item> <item>"> <incoming uri="imap+ssl+://" username="$email"/> </provider> <provider id="googlemail" label="Google Mail" domain="" username="$email"/> <outgoing uri="smtp+ssl+://smtp.go.Gmail variants --> <provider id="gmail" label="Gmail" domain=""> <incoming uri="imap+ssl+://</item> <item>BBC</item> <item>" username="$email"/> </provider> <provider id="android" label="Android" domain="android. To configure bookmarks for a specific mobile network operator.xml) as illustrated</item> <item>Amazon</item> <item>" username="$email"/> </provider> <provider id="google" label="Google" domain="

com" label="IMAP" username="$email"/> <outgoing uri="smtp://smtp.Mac" domain="" username="$user"/> </provider> <provider id="live" label="Windows Live Hotmail Plus" domain="" label="IMAP" username="$email"/> <outgoing uri="smtp://" username="$user"/> </provider> <provider id="sbcglobal" label="SBC Global" domain="" username="$email"/> </provider> <provider id="netzero" label="NetZero" domain=""> <incoming uri="pop3://" username="$user"/> <outgoing uri="smtp://" username="$email"/> </provider> <provider id="mobileme" label="MobileMe" domain="" username="$email"/> </provider> <provider id="comcast" label="Comcast" domain="" username="$user"/> .com" username="$email"/> <outgoing uri="smtp+tls+://" username="$email"/> <outgoing uri="smtp://"> <incoming uri="pop3://" username="$email"/> </provider> <provider id="earthlink" label="Earthlink" domain="" username="$email"/> <outgoing uri="smtp+tls://" username="$email"/> <outgoing uri="smtp+tls+://" username="$user"/> </provider> <provider id="compuserve" label="CompuServe" domain="" username="$email"/> </provider> <provider id="verizon" label="Verizon" domain="" username="$email"/> <outgoing uri="smtp+tls://"> <incoming uri="pop3://"> <incoming uri="imap://" username="$user"/> </provider> <provider id="dotmac" label=".net" username="$email"/> <outgoing uri="smtp://smtpauth.<incoming uri="imap://"> <incoming uri="imap+tls://" note="@string/provider_note_live"> <incoming uri="pop3+ssl+://"> <incoming uri="pop3://" note="@string/provider_note_live"> <incoming uri="pop3+ssl+://" username="$email"/> <outgoing uri="smtp+tls+://" username="$email"/> </provider> <provider id="juno" label="Juno" domain="" username="$user"/> <outgoing uri="smtp+ssl+://" username="$user"/> <outgoing uri="smtp://" note="@string/provider_note_live"> <incoming uri="pop3+ssl+://" username="$email"/> </provider> <provider id="aol" label="AOL" domain=""> <incoming uri="pop3://" username="$email"/> </provider> <provider id="hotmail" label="Windows Live Hotmail Plus" domain=""> <incoming uri="imap+tls://" username="$user"/> <outgoing uri="smtp://"> <incoming uri="imap://" username="$email"/> </provider> <provider id="msn" label="Windows Live Hotmail Plus" domain="" username="$user"/> <outgoing uri="smtp://"> <incoming uri="pop3+ssl+://

de" domain="" username="$user"/> </provider> <!" username="$user"/> <outgoing uri="smtp+ssl+://" username="$user"/> </provider> </providers> As with all Android application" note="@string/provider_note_yahoo_uk"> <incoming uri="pop3+ssl+:// See Resources and Internationalization in the Android SDK for"> <incoming uri="imap+ssl+://imap. Email/res/xml-mccXXX- .de"> <incoming uri="pop3+tls://" username="$email"/> </provider> <provider id=""> <incoming uri="pop3+tls://" username="$email"/> <outgoing uri="smtp://" username="$user"/> <outgoing uri="smtp+tls://" username="$user"/> <outgoing uri="smtp+ssl+://" username="$email:wq"/> </provider> <provider id="yahoo-uk" label="Yahoo" domain="" username="$user"/> <outgoing uri="smtp+ssl:// the platform will load alternate resources based on the platform configuration values. place the customized providers in a separate providers.xml file and place it under a Mobile Network Code (MNO) specific resource folder. For" username="$email"/> </provider> <provider id="gmx" label="GMX" domain="" username="$email"/> <outgoing uri="smtp://" label="IMAP" username="$user"/> <outgoing uri="smtp+ssl+://" note="@string/provider_note_yahoo"> <incoming uri="pop3+ssl+://plus.web.Common Germany providers --> <provider id="freenet" label="Freenet" domain="" username="$email"/> </provider> <provider id="T-Online" label="T-Online" domain="" username="$email"/> <outgoing uri="smtp://"> <incoming uri="pop3://" username=""/> </provider> <provider id="tiscali" label="Tiscali" domain="" note="@string/provider_note_t_online"> <incoming uri="pop3://"> <incoming uri="pop3://mail.</provider> <provider id="yahoo" label="Yahoo Plus" domain=" UK providers --> <provider id="aol-uk" label="AOL" domain=" To configure email providers for a specific mobile network" username="$user"/> </provider> <!" label="" username="$user"/> </provider> <provider id="bt" label="BT Internet" domain="" username="$email"/> <outgoing uri="smtp+tls://"> <incoming uri="pop3://pop.

xml where XXX and YYY represent the three-digit MCC and two to three digit MNC values. Platform Themes Themes and Styles System level styles are defined in //android/framework/base/core/res/res/values/styles.xml.mncYYY/providers. System-level animations are defined in XML in global resource files located in //android/framework/base/core/res/res/anim/ . Animations Android supports configurable animations for window and view transitions.

and make assertions about various UI elements. your test might launch activities and send key events. You can launch activities and providers within an application. the names of the classes which handle the intents etc. Instrumentation test cases need to be grouped together with an instrumentation test . For example. Instrumentation Framework Classes The following classes help glue together Instrumentation with JUnit testing. Instrumentation gives a handle to the application context used to poke around the application to validate test assertions. You should have a working knowledge of the following:  Android Application Framework  Using adb. Class InstrumentationTestCase Description This extends the standard JUnit TestCase and offers access to an Instrumentation class. InstrumentationTestRunner The instrumentation test runner is an instrumentation that runs instrumentation test cases and injects itself into each test case. the instrumentation needs to be injected into the test case. Write tests inside your instrumentation class any way you see fit. Instrumentation testing allows you to verify a particular feature or behavior with an automated JUnit TestCase. Instrumentation kills the application process and restarts the process with Instrumentation. allowing you to write test cases to test applications at a much lower level than UI screen shot tests. am and various logging functionality  A brief understanding of the application of interest. Each Android application runs in its own process.  JUnit testing. Note that Instrumentation cannot catch UI bugs. For this to work properly.TESTING Instrumentation Testing This document describes how to use the Instrumentation Framework to write test cases. send key events. that is.

ProviderTestCase This class is similar to ActivityTestCase except that it will setup. you can write tests that access the activity using getActivity() and assume it has been set up properly. SingleLaunchActivityTestCase This class is similar to ActivityTestCase except that the activity is launched once per class instead of every time the test case calls setup.html for details). Three additional base classes extend InstrumentationTestCase to allow you to test Activity and Provider classes: Class Description ActivityTestCase This class can be used to write tests for a specific tear down. ServiceTestCase This test case provides a framework in which you can test Service classes in a controlled environment. and hooks by which you can inject various dependencies and control the environment in which your Service is tested.runner with the appropriate target package. InstrumentationTestSuite The instrumentation test suite is a simple extension of the standard JUnit TestSuite that keeps a member Instrumentation variable on hand to inject into each TestCase before running It provides basic support for the lifecycle of a Service. If you write a test case that extends ActivityTestCase. It is used by InstrumentationTestRunner. am is used to start and instrument activities using the adb shell command.] . and provide access to the Provider of your choice. An activity is launched in its setUp() method and finished with tearDown. as shown in the snippet below: > adb shell am usage: am [start|instrument] am start [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-c <CATEGORY> [-c <CATEGORY>] . Understanding the am Command The am command is a command-line interface to the ActivityManager (see http://code..

 adb install Contactstests. the following . to start the Contacts application you can use > adb shell am start -n com. To run your tests./tests. Core Library Core library test cases test the Android library functionality that does not require an Android runtime context.  There should be a Makefile and an Android Manifest file.  make Contactstests: Compiles the test cases. These tests are split into Android library (android.apk: Installs the apk on the device. Framework Tests Framework test cases test the Android application framework or specific Android application functionality that requires an Android runtime context. Suppose you have a makefile with Contactstests as the use the am instrument command with your InstrumentationTestRunner as its For example.* package space) tests at //device/java/tests and Java library (java. packages) tests at //device/dalvik/libcore/.  Tests are located in tests/Contacts/src/com/google/android/contactstests. etc.contacts/..ContactsActivity Platform Test Suites This section provides an overview for various unit and functional test cases that can be executed through the instrumentation framework.  Use the adb shell am command to run them. For example.*. Results are printed as a result of the instrumentation.] [-n <COMPONENT>] [-D] [<URI>] am instrument [-e <ARG_NAME> <ARG_VALUE>] [-p <PROF_FILE>] [-w] <COMPONENT> For example. These tests can be found in //device/tests and //device/apps/AndroidTests. Running Tests Each instrumentation test case is similar to an Android application with the distinction that it starts another application..[-e <EXTRA_KEY> <EXTRA_VALUE> [-e <EXTRA_KEY> <EXTRA_VALUE> .*. have a look in the tests/Contacts directory.  The Instrumentation Test Runner is located at tests/Contacts/src/com/google/android/contactstests/functional/ContactsI nstrumentationTestRunner. javax.

317 OK (10 tests) INSTRUMENTATION_CODE: -1 ..Instrumentation$InstrumentationThread.InstrumentationTestSuite.RequestFocusT est) 8) FAILURES!!! Tests run: 151) at $ adb shell am instrument -w \ Errors: 0 <RETURN> to continue INSTRUMENTATION_CODE: -1 $ All Tests with Default TestRunner behavior If no class or package is passed in to run. at com.runTest(InstrumentationTestSuite..test.snippet displays the output after running the framework tests with one test failing (note the unusual syntax caused by how instrumentations are run via am): $ adb shell am instrument -w requestFocus() should work from ) at android... Time: INSTRUMENTATION_RESULT: test results:=.. InstrumentationTestRunner will automatically find and run all tests under the package of the test application (as defined by the android:targetPackage attribute of the instrumentation defined in its manifest file).InstrumentationTestRunner. Time: There was 1 failure: 1) testSetUpConditions(com..framework.onStart(InstrumentationTestRunner..InstrumentationTestRunner INSTRUMENTATION_RESULT: Test results for InstrumentationTestRunner=.focus..testSetUpConditi ons( at Method) at android.tests/android. Failures: ) at android.

InstrumentationTestRunner ..tests/android.view.286 OK (10 tests) INSTRUMENTATION_CODE: -1 A Single Test Case $ adb shell am instrument -w \ -e class com..tests/android..InstrumentationTestRunner INSTRUMENTATION_RESULT: Test results for InstrumentationTestRunner=...InstrumentationTestRunner INSTRUMENTATION_RESULT: Test results for Focus2ActivityTest=.tests/ OK (8 tests) Running a Single Test Suite If you prefer to explicitly state which tests comprise all of your tests. all test packages in your system should have at least one suite called AllTests (see By convention.samples.samples.view. $ adb shell am instrument -w \ -e package com.test. Time: 1.Running all Tests Under Single Package If you have many tests under one package.. To run all of the tests using the AllTests suite for the api demos test app: $ adb shell am instrument -w \ -e class com.samples.359 OK (4 tests) INSTRUMENTATION_CODE: -1 A Single Test $ adb shell am instrument -w \ -e class com.. Time: 2. you can define a test suite and run that directly.tests/ \ \ INSTRUMENTATION_RESULT: Test results for Center \ com.. Time: 1..Focus2ActivityTest \ com.samples. use the -e package <packagename> option to run all tests under that package without having to manually create a test suite.

tests/android. and a src directory that mirrors the src directory of the tested application. For example. refer to the ApiDemos tests as models (located at //device/samples/ApiDemos). java samples/ApiDemos/tests/src/com/google/android/samples/view/Focus2AndroidTest. samples/ApiDemos/tests/src/com/google/android/samples/ApiDemosTest. Time: 0.xml samples/ApiDemos/tests/src samples/ApiDemos/tests/src/com samples/ApiDemos/tests/src/com/google samples/ApiDemos/tests/src/com/google/android samples/ApiDemos/tests/src/com/google/android/samples samples/ApiDemos/tests/src/com/google/android/samples/AllTests.51 OK (1 test) INSTRUMENTATION_CODE: -1 Attaching a debugger to your test In order to debug your test code. This section provides an overview of the test structure with ApiDemos. samples/ApiDemos/tests/src/com/google/android/samples/os samples/ApiDemos/tests/src/com/google/android/samples/os/MorseCodeConverterTes t.j ava . instruct the controller to stop and wait for the debugger by adding -e debug true to your command samples/ApiDemos/tests/src/com/google/android/samples/view samples/ApiDemos/tests/src/com/google/android/samples/view/Focus2ActivityTest. $ adb shell am instrument -w \ -e debug true \ Location of Files Test packages should use the following structure and include Android.test. This causes the test runner to stop and wait for the debugger just before calling your setUp() method. Files are located within a tests directory found in the root directory: $ find samples/ApiDemos/tests samples/ApiDemos/tests samples/ApiDemos/tests/Android.InstrumentationTestRunner Writing Tests When writing tests.INSTRUMENTATION_RESULT: Test results for samples/ApiDemos/tests/AndroidManifest.

RUN_INSTRUMENTATION" /> <!-This declares that this app uses the instrumentation test runner targeting the package of LOCAL_MODULE_TAGS := tests # Include all test java files. by # running the tests using an instrumentation targeting ApiDemos. # Add appropriate copyright banner here LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) # We only want this apk build for" android:targetPackage="com.InstrumentationTestRunner" --> <instrumentation android:name="android.tests appended.Contents of makefile The contents of the makefile are similar to a normal application with the addition of a LOCAL_INSTRUMENTATION_FOR declaration. src) # Notice that we don't have to include the src files of ApiDemos To run the tests use the command: "adb shell am instrument -w com.permission."/> </manifest>" package="com.test. LOCAL_PACKAGE_NAME := ApiDemosTests LOCAL_INSTRUMENTATION_FOR := ApiDemos include $(BUILD_PACKAGE) Content of Manifest Use the following example to create an AndroidManifest. The name of the test application is typically the same as your target application with . LOCAL_SRC_FILES := $(call all-java-files-under.samples.tests"> <uses-permission android:name="android. allowing the tests that are run with the instrumentation to get access to all of the classes of your application without having to build the source into the test app.test.samples" android:label="Tests for Api Demos. we # automatically get all of its classes loaded into our environment.xml file that declares the instrumentation. Specify that the framework supplied Instrumentation TestRunner targest the package of your application. # Add appropriate copyright banner here <manifest xmlns:android="http://schemas.

the snippet below displays the test runner for the framework tests.tests/android. and another that defines all of the tests within the package.InstrumentationTestRunner New Instrumentation TestRunner Create a class that derives from this class. one that returns the class loader of the target public class FrameworkInstrumentationTestRunner extends InstrumentationTestRunner { OUTPUT SCREENS Create an Android Virtual Device (AVD): .The following snippet will prefix the /android. You must override two abstract methods.test.InstrumentationTestRunner when running tests from the command line: $ adb shell am instrument -w \ com.test. For example.samples.

Configure the ASE: .

2′ and press it. We need to install the Python interpreter. and you should see it extract the various Python . .zip files you had put on the virtual SD card earlier.  New buttons along the bottom. press “Add”  AH. so.  Along the bottom of the UI three buttons will pop up. This will launch the Android Scripting Environment.  This will clear the screen with only one option. Press the “MENU” button again. press “MENU”.  This will start an extraction process. “Shell”.6. Press the middle one “Interpreters”. and give you a screen saying “Start adding scripts and Interpreters by pressing the menu button”. a big list of stuff to install! Scroll down to ‘Python 2. Select the ASE icon.

Success! OPEN THE EDIT MODE . “Shell” and “Python 2. Press Python…  This launches a Python shell. Now the UI has two options.6.2″.


Press ‘ Hitting the return button twice will take you to another menu that has all the default Python modules previously installed: notify_weather. etc. saychat. executing a variety of test suites on the emulated':  This will run that module.  Pressing menu can take you into a module edit mode as well:  REFERENCES . . www. https://source.1. 2.