Viewing Android Source Code in Eclipse

This is a quick note to pass along a tip about viewing Android source code while you are working in Eclipse. If you’ve ever been frustrated with not knowing how the Android team did something in their code, you will really appreciate the Eclipse add-on for “Android Sources”. You can find it at http://code.google.com/p/adt-addons/. The installation instructions are about a screen or two down the page. The title of the section is “Android Sources”.

Having access to the source jar really makes debugging easier. As you check the stack to see how your methods were called, you will see source code for the Android classes.

Viewing Source In DebuggerViewing source of class

Just follow the instructions on the adt-addons page to install. When that finishes, it’s not really obvious that anything has happened. So you might want to check the installed software window in Eclipse. It should look like this:

Installed Software window

Another thing you can check is that the source code has been attached to the Android jar file. Go to one of your Android projects in Eclipse and find the Android jar. Expand that and pick a class within one of the packages. When you click the class, you should see the source code for the Android class. For my project, which uses Android 2.2, it looks like the following:

Screenshot of Android source in Eclipse

Thanks go to the ADT-addon people for their work. And thank you, members of the TriDroid meetup group, for sharing the tip.

About these ads

4 Responses to “Viewing Android Source Code in Eclipse”


  1. 1 figus salvatore June 30, 2011 at 4:24 pm

    Installed the plugin. Now what?

    • 2 blahti July 1, 2011 at 5:54 am

      Two things to try:
      (1) The next time you are debugging and move back in the stack to the point that called your code, check the view in the debugger. The Android source code is there. So if there is something not particularly clear about what an Android method does, you can browse around right there in your debugging session.
      (2) You can go directly to the Android source code in the Eclipse Package Explorer and Project Explorer. I updated this blog post (above) and added a screenshot that shows that.

  2. 3 figus salvatore July 2, 2011 at 6:26 am

    Thanks!

  3. 4 ololosh November 19, 2011 at 8:39 am

    Thank you!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s





Follow

Get every new post delivered to your Inbox.

Join 72 other followers

%d bloggers like this: