Where is the source code site?

Android source is published at http://source.android.com. According to the site

Android is the first free, open source, and fully customizable mobile platform. Android offers a full stack: an operating system, middleware, and key mobile applications. It also contains a rich set of APIs that allows third-party developers to develop great applications.

The code was open sourced around October, 2008. The anouncement available at http://source.android.com/posts/opensource reads:

You'll be hearing a lot about Android devices. We've all put a lot of effort into the first Android device, and I'm really happy with the way it turned out. But one device is just the beginning.

Android is not a single piece of hardware; it's a complete, end-to-end software platform that can be adapted to work on any number of hardware configurations. Everything is there, from the bootloader all the way up to the applications. And with an Android device already on the market, it has proven that it has what it takes to truly compete in the mobile arena.

Even if you're not planning to ship a mobile device any time soon, Android has a lot to offer. Interested in working on a speech-recognition library? Looking to do some research on virtual machines? Need an out-of-the-box embedded Linux solution? All of these pieces are available, right now, as part of the Android Open Source Project, along with graphics libraries, media codecs, and some of the best development tools I've ever worked with.

Have a great idea for a new feature? Add it! As an open source project, the best part is that anyone can contribute to Android and influence its direction. And if the platform becomes as ubiquitous as I hope it will, you may end up influencing the future of mobile devices as a whole.

This is an exciting time for Android, and we're just getting started. It takes a lot of work to keep up with the changes in the mobile industry. But we want to do more than just keep up; we want to lead the way, to try things out, to add the new features that everyone else is scrambling to keep up with. But we can't do it without your help.

As Android is a collection of many many projects, you can also look at the list of related android platform projects at

http://source.android.com/projects

The goal of this note to be able to examine the java source code that comprises the android.jar and be able to debug into the source code if needed. You can explore most of these projects online at

http://android.git.kernel.org/

How can I get the source for android.jar?

Any of the packages above at http://android.git.kernel.org/ can be downloaded using "git" tools. According to the Git website at

http://git.or.cz/

Git is an open source version control system designed to handle very large projects with speed and efficiency, but just as well suited for small personal repositories; it is especially popular in the open source community, serving as a development platform for projects like the Linux Kernel, Ruby on Rails, WINE or X.org.

Focus of this note is not download all of Android platform but just look for the source for android.jar. If you were to download and build the entire Android platform the page at http://source.android.com/download provides the details.

You can download just the source code by using the following url

http://git.source.android.com/?p=platform/frameworks/base.git;a=snapshot;h=HEAD;sf=tgz

Notice how you have used one of the git commands itself to locate the right project and download it. When you download it you can use pkzip on windows to expand the files.

How can I see the source files online?

If the goal is simply to look at a source file or look for a source file containing certain words, you can do this online with out downloading anything using the "git" interface itself.

For example to see the java files belonging to android.jar visit the following page

http://android.git.kernel.org/?p=platform/frameworks/base.git;a=summary

Once you are there, you will see a drop down. Pick "grep" from the drop down. Type in the text that you would like to see in a file that you want to search for that string just like grep. You will see a list of files in response. Click on one of the file names to open the file up in the browser. Very convenient.

At times the file you are looking for may not be in the fraeworks/base directory or project. Then you need to find the list of projects and see each one step by step. The url for this list is:

http://android.git.kernel.org/

There is not a way that I know off where you can grep across all projects. So you will need to know which project belongs to which facility in Android. For example the "graphics" related libraries are availabe in the project of "skia" available at

http://android.git.kernel.org/?p=platform/external/skia.git;a=summary

Here is an example looking at teh SkMatrix.cpp file that has the source code for transformational matrix that is useful in animations:

http://android.git.kernel.org/?p=platform/external/skia.git;a=blob;f=libcorecg/SkMatrix.cpp

In a similar tone here is the source code for the corresponding cpp header file for SkMatrix

http://android.git.kernel.org/?p=platform/external/skia.git;a=blob;f=include/corecg/SkMatrix.h

How can I debug using the source for android.jar?

Eclipse has a facility that allows you to attach source to a library jar such as android.jar. The general approach is as follows.

Look for the jar that you have source for in the "Referenced Libraries" underneath your project in the project explorer. Expand "Referenced Libraries" by opening the plus sign.

Click on the jar file and right click for properties. You will see an option called "Java Source Attachment". Specify the path or the jar file of the source here.

These steps may vary depending on the eclipse release. However bottomline is that you can attach source to an existing jar.

Occasionally though the source options for a jar are turned off as the jar file is indicated as immutable system library. In such cases you may want to drop or remove the jar file and that library and explicitly add it as a user library as if you are attaching that jar yourself and then proceed to attach source code to it.

This indeed is the case for android.jar for the projects you have created as "android" projects through the android development Tool (ADT) plugin for eclipse. So you will have to "remove" that library and reattach it as just another library. Now you can attach the source folder that you have downloaded using one of the steps above. Now you will be able to step into the android java source code. Some of these java calls may end up in calling native code that is in "c" or "c++" in which case you can use the browse online option to look at the source code manually through a web browser.