Monday, November 22, 2010

How to get the Android API source code

The Android SDK doesn't include the API source code and the JavaDocs are often pretty sparse. Google has closed this issue as declined, so it doesn't look good for getting this fixed officially any time soon.

Here's a workaround:

cd [android SDK installation]
mkdir source
cd source
git clone git://android.git.kernel.org/platform/frameworks/base.git -b froyo froyo
git clone git://android.git.kernel.org/platform/frameworks/base.git -b eclair eclair

symlink [android SDK installation]/source/froyo/base/core/java to [android SDK installation]/android-8/sources
symlink [android SDK installation]/source/eclair/base/core/java to [android SDK installation]/android-7/sources

Repeat for donut and cupcake as needed.

If you are running Windows, you'll probably need Windows Sysinternals Junction to create the symlinks.

After doing this, you can step in while debugging and/or view the code in Eclipse.

This is absolutely ridiculous, though. We shouldn't need to check out a 444 MB git repo (the eclair branch is "only" 373 MB) when a couple of 3.5 MB JARs could be included in the SDK instead.

No comments: