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.
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:
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:
Thanks go to the ADT-addon people for their work. And thank you, members of the TriDroid meetup group, for sharing the tip.