新版本的ADT r17插件为Eclipse添加了自动设置JAR依赖项的功能。/libs文件夹中的任何.jar文件现在都被添加到构建配置中。不幸的是,Android依赖类路径容器是不可修改的。
如何将javadoc和源代码附加到自动插入的.jar(从/libs文件夹)?
新版本的ADT r17插件为Eclipse添加了自动设置JAR依赖项的功能。/libs文件夹中的任何.jar文件现在都被添加到构建配置中。不幸的是,Android依赖类路径容器是不可修改的。
如何将javadoc和源代码附加到自动插入的.jar(从/libs文件夹)?
当前回答
我尝试了以上所有的方法,但没有一个对我有效。我想出了一个永远有效的方法。基本上,罪魁祸首是ADT处理“libs”文件夹的方式,所以我放弃使用“libs”文件夹。相反,我创建了一个“libraries”文件夹并使用它。
你可以这样做,它总是工作-即使ADT应该改变它如何改变它处理“libs”文件夹在未来:
Create a "libraries" folder. Create a sub-folder under it for each library. Put all of the files for each library in the appropriate folder (java jar file, source jar file, javadoc jar file, etc). Add the java jar file for each project in the "Libraries" tab for the Java Build Path by clicking on the Add Jars... button to add the jar from the library sub-folder in the "libraries" folder. Attach the source/javadocs to each project by opening the project in the "Libraries" tab, selecting the desired item, and clicking on the Edit... button to add the source/javadocs from the library sub-folder in the "libraries" folder. Check the checkbox for each project in the "Order and Export" tab for the Java Build Path. After verifying that all libraries have been moved delete the "libs" folder.
按照上面的步骤,你的项目会有这样的文件夹:
你的Java构建路径看起来像这样:
在Order和Export中,库被勾选:
其他回答
似乎是一个移动的目标,但在收集了许多地方的零碎信息(包括对这个问题的答案,但未能描述所有必要的细节,或者可能系统在此期间发生了轻微变化)后,这似乎是解决方案,至少到目前为止(2013年8月28日)。
为javadocs打开一个文件夹,不在项目内部。 把你的javadocs解压到它自己的文件夹中。 在lib文件夹中,为每个想要关联javadoc的lib添加一个xxx.jar.properties文件。 在那个属性文件中,引用你解压javadoc到的文件夹(在Windows上,转义反斜杠):
doc=d:\\Android\\javadoc\\libGoogleAnalyticsServices
在Eclipse中关闭并重新打开项目(刷新是不够的)。现在,当您将鼠标悬停在适当的类上时,应该会看到工具提示。
没有遵守这些步骤中的任何一个(不解压缩javadoc,引用文件而不是文件夹,等等)似乎会破坏它。
我尝试了以上所有的方法,但没有一个对我有效。我想出了一个永远有效的方法。基本上,罪魁祸首是ADT处理“libs”文件夹的方式,所以我放弃使用“libs”文件夹。相反,我创建了一个“libraries”文件夹并使用它。
你可以这样做,它总是工作-即使ADT应该改变它如何改变它处理“libs”文件夹在未来:
Create a "libraries" folder. Create a sub-folder under it for each library. Put all of the files for each library in the appropriate folder (java jar file, source jar file, javadoc jar file, etc). Add the java jar file for each project in the "Libraries" tab for the Java Build Path by clicking on the Add Jars... button to add the jar from the library sub-folder in the "libraries" folder. Attach the source/javadocs to each project by opening the project in the "Libraries" tab, selecting the desired item, and clicking on the Edit... button to add the source/javadocs from the library sub-folder in the "libraries" folder. Check the checkbox for each project in the "Order and Export" tab for the Java Build Path. After verifying that all libraries have been moved delete the "libs" folder.
按照上面的步骤,你的项目会有这样的文件夹:
你的Java构建路径看起来像这样:
在Order和Export中,库被勾选:
对于任何给定的jar,如果您希望在编码时在工具提示中看到Javadoc帮助,请执行以下操作: 右键单击项目>属性> Java构建路径>库选项卡。单击罐子旁边的箭头展开。
源附件应该指向实际jar的位置(可能就在java文件夹中)。
Javadoc位置:这里有两个选择:URL和存档。如果这个jar的javadocs是一个文件夹的形式,在第一层包含一个index.html文件,选择“Javadoc URL”并指向该文件夹。 如果你的Javadoc在一个jar中,选择“Javadoc in archive”并指向这个jar。 不要忘记重新启动工作区/关闭并重新打开项目,以使用Javadoc信息更新工具提示。
我希望这有助于为我认为应该是非常简单的任务提供一个简单的答案。
我知道这个问题已经很老了,但是当我昨天遇到同样的问题时,上面发布的解决方案对我来说太烦人了,我发现可以很容易地在项目的.classpath文件中添加源路径定义。然后Eclipse将对其进行改编,您就可以浏览源代码了。
之前的类路径条目:
<classpathentry kind="lib" path="[PATH_TO_MY_JAR]"/>
将路径添加到源后
<classpathentry kind="lib" path="[PATH_TO_MY_JAR]" sourcepath="[PATH_TO_MY_SOURCE_JAR]"/>
希望这能有所帮助
在ADT 22上,我无法访问common -io- 2.4.4 .jar和android-support-v4.jar的Javadoc
这是我解决它的方法:
前提条件:这两个库都列在“参考库”下。 右键单击commons-io-2.4.jar并选择Properties。此窗口显示:
commons-io-2.4.jar与commons-io-2.4-javadoc.jar捆绑在一起,因此我在归档外部文件路径中指定了Javadoc。
我对支持库做了同样的事情:右键单击android-support-v4.jar并选择Properties。此屏幕显示:
这一次,我指定了源目录的路径。