How to add source to eclipse for support v4

本文介绍了一种在Android项目中为支持库附加源代码的高效方法,适用于ADT 20及以上版本。通过创建与目标JAR文件同名的Java属性文件,并设置src属性指向资源位置,可以实现对禁用了源代码位置设置的容器的支持。操作简单且效果显著,特别适合多库引用项目。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I just want to add yet another method of attaching sources for the support library. It requires ADT in version 20 or later. Supposedly this method works for all JARs for which setting source/javadoc location is disabled by the container. Here's what you need to do:

The android-support-v4.jar library lies in the libs directory of your project. In that same directory create a regular Java properties file named exactly like the JAR in question, but with appended .properties extension. So, for our support library it'll be:
android-support-v4.jar.properties.

Open created properties file and set value of property named src to the location where sources for that library can be found. Your file should have one line like:

src=c:/apps/adt-bundle-windows-64bit/sdk/extras/android/support/v4/src

Save the file.

Close and re-open your android project.

Try browsing to one of the support classes. The source attachment should work now.

Worked perfectly in my case.

One thing to note: if src is not an absolute path, it will be resolved starting in the parent directory of the JAR file. Taking support library as an example - if src=support/src, ADT will assume that the class sources are located in libs/support/src.

Short description of this feature written by its author can be found here.

If anyone is interested in how exactly this .properties file is processed, I recommend reading patch set #4, esp. changes in eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/ internal/project/LibraryClasspathContainerInitializer.java :)

Edit

Please also see a fine comment by WindRider about adding sources properly in a project with multiple referenced libraries.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值