22
Dec
image
23

As an Android developer, the first thing I do when I set up Eclipse with ADT on a new machine is hunt down the Android source for the API level I'm working on.

Earlier this month, I added a request for Android 4.0 source to be added to the plugin, and I'm pleased to report that the plugin maintainer just added it to the latest version.

Honeycomb sources are being worked on.

Note: If you already have the plugin installed, you'll need to re-install for this addition to show up.

Developers should understand what I'm talking about, but for the rest of you - this priceless little addition to our development process means whenever we want to see just what exactly Android is doing at a certain point in our programs, we can actually take a peek.

In fact, I oftentimes gain more insight into how the code works (or why mine doesn't work) from looking at the source than from reading documentation. Go try that with iOS...

In other words, if I'm looking at Activity.class, which is part of Android, instead of looking at what you see on the left, I would much rather be looking at what you see on the right:

image image

Left: without source code | Right: with source code

Until I found the plugin I'm about to show you, the process of downloading and packaging the source code for consumption in Eclipse had always been quite painful.

Yes - Android is open, but in order to grab the right source from its repositories, one needs to spend a considerable amount of time first figuring out where all the parts are and then downloading them one by one, praying that they're using the right branch. It's a mess, really - a mess Google shouldn't have left for developers to sort out.

Android Sources Plugin

Enter the Android Sources Eclipse plugin. No more downloading random zips, searching for the right sources, and figuring out what to package where - just install the plugin, restart Eclipse, and all available API levels (currently 3-10, considering Honeycomb isn't open sourced and ICS source hasn't come out yet) are automagically available. 170MB of open goodness.

Here's how to get it up and running in a few clicks:

  1. Start Eclipse, go to Help -> Install New Software.
  2. Click Add...
  3. Enter http://adt-addons.googlecode.com/svn/trunk/source/com.android.ide.eclipse.source.update/ into the Location field and whatever you want into the Name field. Press OK.
  4. Now Select the newly added repository from the dropdown in the Work with prompt. You should see Android Sources as the only available plugin:
    image
  5. Press Next, then Finish, wait, and restart Eclipse at the prompt.
  6. Voila - you're done. You should now be able to step into any Android class (this excludes native functions, however) and examine the source code. Do it during debugging or regular development and stop staring at boring class definitions.
  7. Code our next favorite app.
  8. ???
  9. Profit.

Update: qbking77 from ACS made a video running through these instructions:

Enjoy!

Artem Russakovskii
Artem is a die-hard Android fan, passionate tech blogger, obsessive-compulsive editor, bug hunting programmer, and the founder of Android Police.
Most of the time, you will find Artem either hacking away at code or thinking of the next 15 blog posts.

23
Responses
to "[Update: Now With ICS Source] Gold For Android Developers: Add AOSP Source Code To Eclipse With The "Android Sources" Plugin"

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>