manski's blog

Android Source Code in Eclipse

Google made developing an Android app fairly simple. Everything you need can be downloaded for free from Android’s development site. This includes the Android API, an Android emulator (for running Android apps directly on your computer), and an Eclipse plugin called ADT (Android Developer Tools). However, there is was one thing missing: the Java source code.

Since Android 4.0

Since Android 4.0 (API level 14) you can download the source code by using the “SDK Manager”.

android-sources.jpg

After downloading them, you’ll find them under <android-sdk>/sources.

Before Android 4.0

The Problem

Despite the fact the Android is (supposed to be) an open source project, the downloads don’t include the source code of Android. So, when opening an Android class in Eclipse, you may see something like this:

"Source not found" error in Eclipse

To solve this problem you had to manually download the whole Android source code (which contains much more than just the Java source code files) and then manually assemble a source files directory from the Java files scattered throughout the Android source tree. Very tedious and certainly not very simple.

The Solution

Fortunately, there is a Google Code project named “adt-addons” aiming to solve this problem (for API levels 13 and lower). The project actually consists of several Eclipse plugins, but the one you want is called “Android Sources”. You can either search the instructions on the project page, or follow them (nicely formatted) here.

Basically what you need is to install the “Android Sources” plugin (about 170 MB). Here’s the update URL:

http://adt-addons.googlecode.com/svn/trunk/source/com.android.ide.eclipse.source.update/

After installing the plugin, simply restart Eclipse and the Android source code is already attached to the Android classes.

Sources found for Android classes

3 comments

  1. shubham said:

    thanks for your support.
    But like if I want to add source which I am modifing, how can I .

    please let me know if do u have any idea.

    thanks

  2. ines said:

    can’t install the plugin, not even by command…help please

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.