Learn How To Work With the Android Source Code

Page content

In this series of articles we are having a look at some tools and resources that make our Android development projects more easy to build. Now its time to talk about the Android source code. Android is an Open Source platform, this means that the source code is available for everybody, like in a GNU/Linux system. Everybody can download, modify and create his “own Android platform”. Even more, we can help the Android community and fix for ourselves code mistakes we can find within this code.

This time, we are going to have a look at the code, to see how Android Apps are put together.


In the source code web page, we can find all information we need to get the source code. The whole code is about 2Gb, and we will need 6Gb to compile it. Now, we can only use Unix-like machines to compile it, so if we are working under Windows, we can not do that. In our case, we want only have a look to the source code, we don’t want (for now) to compile it.

Lets have a look to the Repository web page we can find a large list of projects. They are the source code of the kernel, framework,libraries, Applications and much more!

First of all we have to know what we are looking for, because if we don’t know that, we can become crazy looking inside the project folders.

Imagine that we want to know how the AlarmClock is programed. We find this project as platform/packages/apps/AlarmClock.git.

Inside every project, we can find deferents tags “Summary, shortlog, log…” we are interested in the “summary” and “tree” ones. Why the “summary”? Here we can find all information about the project we need. In the “tree” tag, we can surf trough the project folders and files.

We have to take account that this code is always changing, they are working with a more advanced SDK than ours. So maybe, some of the “main” branches code would not work in our applications because they depends of the news SDK classes. If we want to get the source code of the public SDK (1.0) we have to go to “release-1.0” line, in the “summary” tag.

If we surf trough the “tree” tag, we can see every java, xml and resource files of the project. We can download them individually or as a package.

Getting the source code

We have to specify the source we want to download, is it a source code of an older version of the SDK? Or is it the source code of the actual development SDK? We are using the “older” version of the SDK, 1.0 (the public one). So in this case we can just download the packages looking for the snapshot tag. This will download the project branch.

If we want to download the, still in development source code, we have to use a external tool:


We can use this tool in all Operating Systems.

So, once we have this installed, to download a full branch of a project just use this command in the command line:

git clone git://android.git.kernel.org/ + project path.

Once this is done, we can have a look inside the folders and files more easily than using the web browser.

Some Hints

We do have to take several other aspects into consideration.

-The main branches of the repository are still in development, so they are using a different SDK that the public one. If you want to get the code from the public SDK (1.0, now) Look in the “release-1.0” link.

-Some classes are NOT PUBLIC like android.os.ServiceManager, android.view.IWindowManager, etc, they are implemented in the mobile devices, but not present in the SDK .jar. This is because these classes are private APIs and may change/disappear in any release

This post is part of the series: How to- Develop Applications on Android: One more step

In this second Serie of articles we will continue working on Android and Eclipse.This time, we will see different resources to make Android apps development more easy.

  1. How to Create Your UI Using DroidDraw
  2. Guide to the Dalvik Debug Monitor Service for Android
  3. Working With The Android Source Code
  4. Guide to Using Google Android Databases
  5. Guide to Android Development Terms