October 23, 2014

Resource Roundup: Android Source Code

Much has been made of Android being open source. Strategically, this is of huge importance. Tactically, though, your average Android application development may feel somewhat locked out of the source code, simply due to volume. The entire set of Android source code takes up 2.1GB, which means learning anything from it may be as difficult as finding a needle in a haystack.

So, here’s your map to some needles of interest.

First, the source code as a whole is hosted on http://source.android.com/, and any questions you may have about the source code should go on one of the discussion groups related to the source code itself.

While the source is hosted as a roster of git repositories, your easier way to find what you want will be through the Web. There are two approaches for this:

  1. Use Google Code Search, restricting your search to things in the Android package. For example, you can search for references to specific classes, like SQLiteOpenHelper, via package:android SQLiteOpenHelper. This is especially useful when you want to find other classes that reference a particular class of interest (e.g., which Android built-in apps use SQLiteOpenHelper).
  2. Browse the source code via GitWeb.

Here are some of the more useful GitWeb trees for Android SDK developers:

Browsing the trees will get you to the source code for individual classes.

If you are looking simply to reuse some code (under the Apache License 2.0), it is probably simplest to just cut-and-paste. For example, DroidEx was created by examining some of the classes that make up DDMS and hierarchyviewer, to see how they accessed the screenshot service offered by Android devices and emulators.