Android: Attaching Sources to Libraries in Eclipse
Android: Attaching Sources to Libraries in Eclipse
Since ADT r17, Android projects in Eclipse have had a nice property: all jars in your libs directory have been automatically picked up by Eclipse projects under a magic “Android Dependencies” entry in the build path. Ant builds use the same conventions, so adding a library is as simple as dropping it into the right directory. Unfortunately, though, this magic came with a major limitation: there was no way to attach sources to these libraries (see issue 27940). This led me to duplicate build path entries manually just to get source attachments.
Good news: in the just-released r20 version of ADT, Google have provided a solution to this problem. It’s not well advertised, but if you check out comment 21 on the aforementioned issue, you see that by creating a properties file for each library, you can tell ADT where to find the sources. So, for example, if you have a jar named:
some-library-1.0.jaryou can create a properties file alongside it named:
some-library-1.0.jar.propertiesWithin the properties file you can add a src property set to the relative (or absolute, but that’s version-control-unfriendly) path of the source jar, zip or directory. Say, like me, you put it in the libs/src subdirectory, your properties file might look like:
src=src/some-library-1.0-sources.jarOnce you’ve added the properties file, refresh the project in Eclipse and voilà: the sources will be attached! A similar property named doc is supported for javadoc attachments.
Although this new feature is very welcome, I feel like it could use a bit more fine tuning. The main issue is the need to create a separate properties file for each jar. I keep my source jars in predictable locations, with conventional names, so I should be able to configure the convention once and have everything Just Work from then on. Heck, I’m not sure why there isn’t a default convention, which I could just follow with no further configuration!
===============================================
注:
上文所说的路径有错,properties文件必须放在libs目录下才能生效,而不能放在libs/src目录下
更多相关文章
- 修改android virtual device路径
- Android调用系统自带的文件管理器进行文件选择并获得路径,android
- Android Studio中配置代码和资源的路径
- Android Studio apk生成路径
- Android拷贝图片到指定文件路径
- 修改Android Media Scanner的扫描路径
- Android修改Eclipse 中的Default debug keystore路径,以及修改and
- 直播源码Android实现 曲线路径动画
- android中获取当前程序路径