Posts Tagged 'source code'

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.



Follow

Get every new post delivered to your Inbox.

Join 72 other followers