Build Overview


Getting the source code

Branches

We currently have the following possible branches:
 dev branch release branch IntelliJ Notes
 studio-1.0-dev studio-1.0-release 13.x This is the branch for 1.0 work
 studio-1.1-dev studio-1.1-release 13.x This is the branch for 1.1 work
 studio-master-dev studio-master-dev 14.x This is the work for post-1.1 work

We have auto-mergers going from studio-1.0-dev -> studio-1.1-dev -> studio-master-dev

Right now, we will not accept random contributions in studio-1.0-dev. If you have what you think is a critical fix, please talk to us first so that we can plan for this.

The branches ub-tools-idea133 and ub-tools-master are deprecated.

Doing a Checkout

First, you'll need to install the prerequisites for your platform. This means you'll have git, a C compiler, etc. There are quite a few steps here, and it's all platform dependent, so go to the official build instructions where we have detailed instructions:  http://source.android.com/source/initializing.html.

Some of the requirements are not needed (case-sensitive file system for instance), unless you also plan on building the platform. You will still need XCode to build the emulator.

Once you have everything configured, download the 'repo' tools by following the instructions here: http://source.android.com/source/downloading.html

Then you can check out the source code using the following commands in a shell:
$ mkdir studio-1.1-dev
$ cd studio-1.1-dev 
$ repo init -u https://android.googlesource.com/platform/manifest -b studio-1.1-dev
$ repo sync
(You can obviously call the top level directory what you want; those of us who check out multiple branches prefer to name the directories after the branches.)

During the repo init command, it will ask you for your name and e-mail address; these will be used later if you decide to check in changesets and upload them for review.

Doing a checkout of a specific release

We are starting to tag releases. This means you can use the tag to get the source code for a specific version. We are currently using the following tags:

 Gradle gradle_x.y.z 
 Studio TBD
You can see all available tags here: 
https://android.googlesource.com/platform/manifest/+refs

For instance you can do a checkout of version 0.13.1 of the Gradle plugin with the following command:

$ repo init -u https://android.googlesource.com/platform/manifest -b gradle_0.13.1
$ repo sync

Building

The parts of the SDK that can be build with the ub-tools-* branches are only the IDE components and the SDK Tools. Each component is build differently due to varying build systems.

None of them uses the make-based build system of the platform.

Building Android Studio

Historically, building the Android tools required building the full Android SDK as well, since for example the emulator needed the system image.

However, we've been gradually migrating the tools source code over to a more independent setup, and you can now build the Android Studio IDE without a full Android checkout and without a C compiler etc. The instructions for building Android Studio are listed in the Building Android Studio page; the remainder of this document documents the process for building the rest of the tools (the Eclipse plugin, the emulator, etc.)

Building the Android Gradle Plugin

For instructions, see Building the Android Gradle Plugin.

Building the Linux and MacOS SDK

This part only builds the SDK Tools. Follow these steps:
$ mkdir -p out/dist
$ ./tools/buildSrc/servers/build_tools.sh `pwd`/out `pwd`/out/dist 1234

This will build the SDK Tools for your current platform. the result is located in out/sdk/

This is composed of
  • The emulator and associated executables and libraries
  • Java-based standalone tools
  • Monitor

To work on the Java-based tools only, you can open the IJ project located in tools/base.

To build / test the java tools only:

$ cd tools/
$ ./gradlew assemble // builds only
$ ./gradlew check // runs tests as well.

Building the Windows SDK
These instructions are currently obsolete. Coming soon.

Full Windows SDK builds are only supported on Linux -- most of the framework is not designed to be built on Windows so technically the Windows SDK is build on top of a Linux SDK where a few binaries are replaced.

Setup:
$ sudo apt-get install mingw32 tofrodos

mingw32 is the cross-compiler, tofrodos adds a unix2dos command

To build:
$ . build/envsetup.sh
$ lunch sdk-eng
$ make win_sdk

Note that this will build both a Linux SDK then a Windows SDK. The result is located at
   out/host/windows/sdk/android-sdk_eng.username_windows/


Building the Eclipse-based Tools.

To set up your Eclipse environment to build, edit and debug the Eclipse plug-ins for Android, see the "Building the Eclipse-Based Tools" document.

Additional Tools

The next step is preparing your setup depending on which project you want to work on:
  • Traceview, Hierarchy Viewer and DDMS are all setup as follows:
    • The core logic resides in the Java projects under sdk/traceview, sdk/hierarchyviewer2 and sdk/ddms respectively. Import these projects into Eclipse.
    • The above projects generate jar files that are then referenced by their corresponding plugins. traceview-plugin, hierarchyviewer-plugin and ddms-plugin, all of which are present under sdk/eclipse/plugins.
  • TODO: add instructions to work on emulator.