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:
  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:


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.

  • PhineasJW

    Great tip. Thank you Artem!

  • Spartacus

    Now I just need for the ICS source to be released.

  • http://acsyndicate.net qbking77

    Made a how to video showing this process! Feel free to add it to the article :)


    • http://www.AndroidPolice.com Artem Russakovskii

      Added, thanks.

  • http://www.bluelightdev.com Jason

    Thanks! This has been a huge gripe for me in Android Dev, much appreciated.

  • Matthew Patience

    Wow, automagical.

  • http://www.c-labs-android.de Ansgar

    Nice, thanks! That will be helpful!

  • http://decodeumangkedia.blogspot.com Umang

    I didn't understand.. How to open and use the source and open the class from it??

    • http://www.AndroidPolice.com Artem Russakovskii

      You can follow any class, variable, function etc by using the Open Declaration shortcut. I set mine up to be F3. Open Eclipse -> Windows -> Preferences -> General -> Keys and search for "Open Declaration"

  • fifarunnerr

    I'm stuck at number 7, what's you guys next favorite app?

    • http://www.AndroidPolice.com Artem Russakovskii

      You're going to have to top Poop Salary I'm afraid.

  • Tijl

    I go a little further than that. I like to have all the APIs available, not just the public ones.

    I made some Groovy scripts that will compile the android.jar and generate a source zip. (normally you'd need linux for that). I only used them for myself but when some other people started using them I put them on GitHub:


    It's a way more of a manual process (you'll have to find out which directories to include, which is a bit different between each API level release), but in exchange you get access to the "hidden" APIs that Google engineers use all the time.

    For example, you'd not be able to edit the standard applications (the ASOP dailer, homescreen, etc) without these APIs.

  • Brandon

    If I wanted to learn Android development, should I learn c+ + first?

    • http://www.AndroidPolice.com Artem Russakovskii

      Not at all - you need a good foundation of OO, and then you can go straight to Java. Knowing C++ is never a bad thing, of course.

  • simon

    Thanks so much for this.
    Easy to set up and immediately useful.

  • Ninja Developer

    I have the plugin installed but still can't access the source code. Is there an additional step to follow after installation

  • rest_of_the_world

    It is great and thanks for sharing with us i have a question though, does it slow down eclipse's start up ?

  • http://acsyndicate.net Parabola949

    Seriously, thanks much for this. Now if only we could get to a point of being able to compile source from Eclipse, or at least Windows. All my machines are Windows because of work lol

  • Efi MK

    Thank you for your post. I'm still unable to view the source when using Maven.

    Any idea what might be the problem ?

  • GV.Srinivas

    Very Good Post..Keep on posting the stuffs.

  • Jordi

    Not working on Ganymede version of Eclipse. Any idea why? Should I add some path or something to my existing projects?

  • edd

    I reckon myself pretty good, but this is above me, but I still thank you for bringing it to the people who supply me with si much joy. And anyone who writes ??? / Profit deserves a giant hug!

  • Reala

    I just had a nightmare and thought I woke up in my first java class. Mad props to you Java devs. I just don't have the patience to go beyond the basics.

    I used to work on assignments for hours only to find I was missing a semicolon that did not prevent my programs from compiling only from executing. I may be to old for it.....Or maybe the blame lied on my teacher being a poor teacher. Anyhow I learned the basics.

  • http://www.facebook.com/Isabaellchen Isabelle Sandow

    Gah, just downloaded 5 gigs of source code..... Why didn't i find this post earlier... Stupid universe/me :D