17

How to generate custom javadoc for android 1.4 compatibility package?

The reference docs are available online (example), but is there some place where I can get a zip with javadoc available offline?

I suppose using the javadoc would be pretty simple, just a matter of setting the javadoc location for the compatibility jar.

Riyaz Mohammed Ibrahim
  • 9,505
  • 5
  • 26
  • 33
Corneliu Dascălu
  • 3,900
  • 1
  • 28
  • 38

6 Answers6

28

You can generate your javadoc offline on your own from the source code. Just navigate to your android sdk directory then do the following

cd <path_to_android_sdk>/extras/android/compatibility/v4/
mkdir docs

For Windows:

javadoc -d docs -sourcepath src\java -subpackages android.support.v4

For Linux/Mac:

javadoc -d docs -sourcepath src/java -subpackages android.support.v4

This will generate your javadocs for you locally in the docs directory that you just created.

Then in your eclipse android project, go to your project properties where you added the your android-support-v4.jar, edit it's properties and add the the path to the javadocs you just created.

That should work!

ADT 17+ issues:

As some of you have pointed out. There have been issues getting Eclipse to see the attached javadoc for ADT 17+. This is a known issue and a bug has been filed. This is not related to the way you generate the javadoc (as I described above), rather this is an issue with ADT 17+ integrating with Eclipse. Someone has described a workaround and it can be followed here:

http://code.google.com/p/android/issues/detail?id=28801

wnafee
  • 2,126
  • 16
  • 23
  • its 'src/java' on a mac. w00p w00p ty – Blundell Jan 04 '12 at 08:54
  • **NOTE:** since ADT 17 this solution no more works. [Source](http://code.google.com/p/android/issues/detail?id=28801) – Indrek Kõue Aug 08 '12 at 06:50
  • You can still generate the javadoc fine using what i wrote above (which was the purpose of the question). If there are issues with Eclipse and ADT now allowing you to see it within the IDE that's another issue that needs to be resolved. Thanks for pointing it out though! good to know – wnafee Sep 03 '12 at 12:49
  • **NOTE:** here is how you get eclipse to see the javadocs: http://stackoverflow.com/questions/9873152/how-to-attach-javadoc-or-sources-to-jars-in-libs-folder (for me, I had to also restart eclipse after, AND keep the docs on the same drive) – pjco Sep 17 '12 at 21:50
  • 1
    Why the extra step of generating the Javadocs if Eclipse would read them directly from the source files? I just created the file `libs/android-support-v4.jar.properties` with a single line `src=/opt/android-sdk/extras/android/support/v4/src` and javadocs appeared in Eclipse. – ccpizza Dec 30 '12 at 11:18
  • I agree with ccpizza, for Windows I would recommend look at http://stackoverflow.com/questions/12628439/how-can-i-enable-javadoc-for-the-android-support-library – jayeffkay Oct 07 '13 at 06:55
12

Problem: If the android-support-v4.jar is in the /libs folder (as the ADT 17+ require) the javadoc is unavailable.


Edit: I have workarounded the problem by linking the offline version of the android javadoc to the android-support-v4.jar. As far as I know it is still not possible to link the online version (http://developer.android.com/reference). Steps:

  1. Download the Documentation for Android SDK from the SDK Manager. You can find it under the latest Android version (4.1)
  2. Link the javadoc folder to your project's folder, in Windows open a console and type: MKLINK /J {PROJECT_PATH}\android_docs {SDK_PATH}\docs\reference
  3. Create the file libs/android-support-v4.jar.properties with this content:

    src=android-support-v4.jar
    doc=../android_docs
    
  4. Close the project and reopen it. Clean if necessary.

  5. The javadoc is linked. Check it by going to any Support library class, like android.support.v4.app.FragmentActivity

Thanks to this answer https://stackoverflow.com/a/11579339/933261

Community
  • 1
  • 1
Juan T
  • 1,018
  • 11
  • 12
  • You can still generate the javadoc offline to view it in a browser or manually. You're describing a problem with attaching it to your IDE to make for easier coding experience. – wnafee Sep 03 '12 at 12:52
  • This is fixed/wrong: http://stackoverflow.com/questions/9873152/how-to-attach-javadoc-or-sources-to-jars-in-libs-folder (for me, I had to also restart eclipse after, AND keep the docs on the same drive) – pjco Sep 17 '12 at 21:52
2

IF YOU'RE ON WINDOWS and get stuck for ages like me, make sure you escape your backsmashes in the properties file, or things will silently fail. (who makes silent failing loaders anyway...)

This this is my properties file:

src=android-support-v4.jar
doc=doc\\android-support-v4_doc

and my dir looks like this:

android-support-v4.docs.zip
android-support-v4.jar
android-support-v4.jar.properties
doc

close project and open, and it all works for me.

bobjandal
  • 2,313
  • 2
  • 15
  • 8
2

The answer by @wnafee is spot on, but if you are using Linux don't forget to use the forward slash character at this location like src/java.

benwh
  • 135
  • 1
  • 5
Tunji
  • 31
  • 3
1

I generated this one based on wnafee's answer: https://dl.dropboxusercontent.com/u/31272696/android-support-v4.zip

maximz101
  • 678
  • 1
  • 8
  • 20
0

I went through all of these solutions and none of them worked. Here is what I did to get it to work:

  1. Navigate to the following folder: D:\\Android-SDK\android-sdk-windows\extras\android\support\v4

  2. Run the command: javadoc -d docs -sourcepath src\java -subpackages android.support.v4

  3. In your project's libs directory, create a file called android-support-v4.jar.properties

  4. In the properties file, add the following lines (change the path to match yours):

    doc=D:\Program Files\Android-SDK\android-sdk-windows\extras\android\support\v4\docs src=D:\Program Files\Android-SDK\android-sdk-windows\extras\android\support\v4\src

  5. In Eclipse, bring up the properties dialog for the Build, then navigate to Java Build Path and select the Libraries tab.

  6. Expand the support library. In my case the path is: D:\Program Files\Android-SDK\android-sdk-windows\extras\android\support\v4

  7. Select Javadoc location. Click on the Edit button and then select the path to the docs. In my case it was: file:/D:/Program Files/Android-SDK/android-sdk-windows/extras/android/support/v4/docs/

  8. Close everything, including Eclipse and restart. You should now be able to browse docs in your code.

Johann
  • 27,536
  • 39
  • 165
  • 279