How can I enable javadoc for the Android support library?

纵饮孤独 提交于 2020-01-09 04:38:26

问题


When using the Android support library for compatibility and try to view the javadoc for, say, FragmentTransaction, I get the following error because there is no associated javadoc file:

android.support.v4.app.FragmentTransaction

Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

The support library is added under the Android Dependencies item in the project properties, and shows Javadoc location: (None) - non-modifiable as shown below. Is there any workaround for this?


回答1:


I've lashed together a project with android-support-v4.jar just in the Android Dependencies part of the package view. I have a class

public class CountriesFragment extends ListFragment {...}

and an import of

import android.support.v4.app.ListFragment;

up above

I created a file android-support-v4.jar.properties in the libs folder. It contains the lines:

doc=c:\\[path-to-android-sdk]\\docs\\reference
src=C:\\[path-to-android-sdk]\\extras\\android\\support\\v4\\src

Presumably you'll have to change to un-escaped forward slashes if not using Windows.

Next right-click the project, select refresh, then you'll get javadoc support. You don't really need the doc entry--the src entry already contains the javadocs.




回答2:


Edited: Refer the following post :

How to attach javadoc or sources to jars in libs folder?

Added:

Under \android-sdk\extras\android\support\v4 directory of your Android SDK installation you will find the sources for android-support-v4.jar (i.e. the src directory) and you can create a jar file of the same using jar command.

Hope it helps :)

Added:

Check this post https://android-review.googlesource.com/#/c/35702/

according to this

Create a file named android-support-v4.jar.properties in the libs directory of your project and add following line into it.

src: <relative or absolute path to the source folder (or archive).>

I tried this solution and it worked for me. Enjoy :)




回答3:


In Eclipse: Go to File Menu-> Open file-> browse your Project directory in workspace -> select the .classpath file openit->

Keep only below entries in this file and remove all others

`<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="lib" path="your dir path without space.../extras/android/support /v4/android-support-v4.jar"/>
<classpathentry kind="output" path="bin/classes"/>
 </classpath>

Save the file. then in Eclipse-> Package Explorer ->right click Project -> Android tools -> Fix Project Properties.

This will add all required files to project , if you want to cross check open .classpath file again and check updates in it.

Run the project successfully :)



来源:https://stackoverflow.com/questions/12628439/how-can-i-enable-javadoc-for-the-android-support-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!