42

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?

enter image description here

Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246

3 Answers3

53

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.

Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246
NickT
  • 23,844
  • 11
  • 78
  • 121
  • 2
    This answer is a better reference: http://stackoverflow.com/questions/9873152/how-to-attach-javadoc-or-sources-to-jars-in-libs-folder – Jason Axelson May 28 '13 at 07:33
  • 1
    It's enough to add the `src` line (especially when the `doc` line doesn't point to an existing folder). Also, I would keep a copy of the properties file in the folder `C:\[path-to-android-sdk]\extras\android\support\v4`. I don't know if it will get automatically picked up in new projects, but at least I have a central location to manually pick it up from :) – ADTC Jul 28 '13 at 05:47
  • Also, this will work even if the support library is in the _Android Private Libraries_ container. You do not need to move it to the _Android Dependencies_ container. – ADTC Jul 28 '13 at 06:03
  • 2
    "Project -> Close project, Project -> Open project" will be enough. – leoly Feb 22 '14 at 10:17
  • If your support library is in the library project then this file (.properties) needs to go to that library project not your working project. – Lukasz 'Severiaan' Grela Nov 07 '14 at 11:58
6

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 :)

Community
  • 1
  • 1
Vishal Vyas
  • 2,571
  • 1
  • 22
  • 39
  • Yes, except then the support library will be in the project twice. It's already in the build path ash shown in the above screen capture. It seems like this would be a problem. – Jeff Axelrod Sep 27 '12 at 19:19
  • Check this http://stackoverflow.com/questions/9873152/how-to-attach-javadoc-or-sources-to-jars-in-libs-folder – Vishal Vyas Sep 27 '12 at 19:24
  • Thanks. I'm going to wait a bit to see if someone comes up with a more elegant solution. Unfortunately, this might be the only way. – Jeff Axelrod Sep 27 '12 at 19:54
0

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 :)