android libs下的源码和文档配置

来源:互联网 发布:小小冰人 知乎 编辑:程序博客网 时间:2024/06/04 23:52

android libs下的源码和文档配置

自从把adt升级到22之后,android项目libs中的第三方包无需手动添加,eclipse会通过com.android.ide.eclipse.adt.LIBRARIES自动添加到目录
Android Private Libraries中,但是坑爹的是除了android可以设置source之外,其他目录下的竟然不能编辑设置了。

随着android的发展,更多好的开源项目不断被提供给我们使用,对于想看看一些第三包源码的同学们来说,这太残酷了。。。
然后在https://code.google.com/p/android/issues/detail?id=27490#c21里,我们看到一个21楼的伙计提供了如下方法

The source attachement in fixed for r20.
If you have library projects you should see the source for those automatically.
As for the original issue in this bug:
- if you want to manually reference libraries in your project, you need to make them exported. If the project is a library then project referencing your library will *not* have access to those libraries.
- adding them to libs/ is the way to have dependencies be automatically resolved when you have several libraries, all depending on 3rd party libs (some of which may be the same or may be conflicting with each other).
Source attachement: to work with the new dependency system, we need to put the source attachement outside of the eclipse config.
Next to any jar files in libs/ simply put a .properties file (foo.jar -> foo.jar.properties). This properties file currently support two properties:
src: relative or absolute path to the source folder (or archive).
doc: relative or absolute path to the javadoc.

The properties file is a standard Java properties file, using  ISO 8859-1 character encoding.
吼吼~~~
基本的设置流程如下
例如:项目中有libs目录,有android-support-v4.jar,
对应的源码和文档我们放在/home/marsuu/libsrc/android-support-v4_source.jar和/home/marsuu/libdoc/android-support-v4_doc.jar目录下

那么我们在libs目录下新建文件android-support-v4.jar.properties  打开编辑

src=/home/marsuu/libsrc/android-support-v4_source.jar
doc=/home/marsuu/libsrc/android-support-v4_doc.jar

保存,关闭项目重开 或者重启eclipse,你可以在开发中直接查看源码文件咯~~~