在Eclipse中开发Android 程序,使用ADT版本如下:
Android Developer Tools
Build: v22.0.5-757759
查看libs中jar中的源代码时,出现下面的提示:
The Jar of this class file belongs to container 'Android Dependencies' which does not allow modifications to source attachments on its entries。
解决的办法:
在libs目录下,也就是要查看jar包所在的路径下,创建一个新文件,文件的名字为 要查看的jar包名字+.properties
比如:我要调试smack.jar 那么创建的新文件名字为 smack.jar.properties
新文件里面包含两行
第一行是代码的关联
第二行是文档的关联
<code class="prettyprint" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit;"><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pln">src</span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">=</span></span><span class="str" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; color: rgb(128, 0, 0);"><span class="str">/Users/</span><span class="pln">david</span><span class="pun">/</span><span class="pln">dev</span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">/</span></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"></span><span class="pln">smack</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">-</span></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pln">sources</span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">.</span></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pln">jar doc</span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">=</span></span><span class="str" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; color: rgb(128, 0, 0);"><span class="str">/Users/</span><span class="pln">david</span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">/</span><span style="color: rgb(43, 145, 175);"><span class="pln">dev</span></span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">/</span><span style="white-space: inherit; background-color: rgb(240, 240, 240);"><span class="pln">smack</span></span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">-</span></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pln">javadoc</span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">.</span></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pln">jar</span></span></code>
补充:
1、源代码文件支持 jar 和 zip 文件格式。
2、支持使用相对路径指向原文件。
例如: dev 和 libs 是同级文件夹,libs里面是jar,dev里面是对应jar的源代码。
<code class="prettyprint" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit;"><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pln">src</span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">=..</span></span><span class="str" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; color: rgb(128, 0, 0);"><span class="pun">/</span><span class="pln">dev</span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">/</span></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"></span><span class="pln">smack</span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">-</span></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pln">sources</span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">.</span></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pln">jar doc</span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">=</span></span><span class="str" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; color: rgb(128, 0, 0);"><span class="pun">..</span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">/</span><span style="color: rgb(43, 145, 175);"><span class="pln">dev</span></span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">/</span><span style="white-space: inherit; background-color: rgb(240, 240, 240);"><span class="pln">smack</span></span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">-</span></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pln">javadoc</span></span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pun">.</span></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent;"><span class="pln">jar</span></span></code>
文件加入后,重新启动ADT,OK!
http://blog.csdn.net/teamlet/article/details/25501745