2012年7月10日火曜日

How can I debug using the source for android.jar?

Eclipse has a facility that allows you to attach source to a library jar such as android.jar. The general approach is as follows.

Look for the jar that you have source for in the "Referenced Libraries" underneath your project in the project explorer. Expand "Referenced Libraries" by opening the plus sign.

Click on the jar file and right click for properties. You will see an option called "Java Source Attachment". Specify the path or the jar file of the source here.

These steps may vary depending on the eclipse release. However bottomline is that you can attach source to an existing jar.

Occasionally though the source options for a jar are turned off as the jar file is indicated as immutable system library. In such cases you may want to drop or remove the jar file and that library and explicitly add it as a user library as if you are attaching that jar yourself and then proceed to attach source code to it.

This indeed is the case for android.jar for the projects you have created as "android" projects through the android development Tool (ADT) plugin for eclipse. So you will have to "remove" that library and reattach it as just another library. Now you can attach the source folder that you have downloaded using one of the steps above. Now you will be able to step into the android java source code. Some of these java calls may end up in calling native code that is in "c" or "c++" in which case you can use the browse online option to look at the source code manually through a web browser.

0 件のコメント:

コメントを投稿