Android Studio: How to attach javadoc

27,059

Solution 1

I found a solution just now since I can't find any other solution for a long time.

suppose:

  1. your lib name is: libxxx.jar
  2. javadoc name is docs.zip

under folder .idea/libraries, you can find libxxx.xml. replace JAVADOC with

<JAVADOC>
  <root url="jar://C:/yourpath/doc.zip!/" />
</JAVADOC>

then ctrl+alt+y to sync the project. (Don't do "Sync Project with Gradle files", it will delete the changes)

Solution 2

I've found & tested a way in which we can add the javadocs without loosing them after a gradle sync.

  1. Right click in Project panel > External libraries > lib-name
  2. Click Library properties Lib props
  3. Click specify documentation URL
  4. And specify an URL. For my machine it was file:///opt/android-sdk/extras/google/google_play_services/docs/reference Add doc url
  5. The result was: added jdoc
  6. And after a project sync I could browse the javadoc of the google play services google play services maps javadoc

Note:

This placed the same JAVADOC entry in the xml identified by Jason but doesn't disappear after doing a sync with gradle

Solution 3

It is possible:

  1. Open Project structure
  2. Navigate to dependency that you want
  3. Press button from the screenshot and provide folder or file

screenshot 1

Another way to attach sources:

  1. Step into class from library (Hover mouse over class name and do CMD + Left click or CMD + B)
  2. You will see decompiled version of class there menu on the top right side of editor "Attach sources.."

screenshot 2

Solution 4

I had problem with answer from Matyas that I wasn't seeing my local .jar library in the External Libraries list, because it only show maven attached libs.

Solution is mentioned here: https://code.google.com/p/android/issues/detail?id=73087#c26

  1. Right click on the "Structure" tab and check "Split Mode" (so you can open both "Project" and "Structure" tabs at same time).
  2. Open both "Project" and "Structure" tabs at the same time.
  3. In "Project" tab select "Android" perspective and then select your module folder (e.g. "app")
  4. In "Structure" window you should now see list of all libraries, including your local *.jar

Continue as in answer from Matyas:

  1. Right click on wanted library and select "Library Properties..."
  2. If you have *.jar with javadocs locally, you can press "add" button (green "+") and search for the file on your disk (you don't have to type "file://" path manually).

Solution 5

Still a current issue as of my posting it seems:

https://code.google.com/p/android/issues/detail?id=73087

Share:
27,059
Ashish Bindal
Author by

Ashish Bindal

Updated on April 27, 2020

Comments

  • Ashish Bindal
    Ashish Bindal about 4 years

    It might be very trivial question, But I couldn't find any option to attach javadoc/source with local jar dependencies (in libs folder) in android project. I can't believe I have spent a hour on such simple stuff :(

    Google search result just tells about adding android documentation or adding javadoc in eclipse. That's not What I am looking for!

  • Scott Barta
    Scott Barta over 10 years
    That's only going to work until the next time you sync your project. Source attachment isn't implemented in Gradle yet so the changes don't get persisted anywhere that will survive a sync.
  • Ashish Bindal
    Ashish Bindal over 10 years
    @ScottBarta Yeah, sources are not persisted. Is there any workaround?
  • AdamVe
    AdamVe about 10 years
    @EugenMartynov When I open project structure and select Android SDK I see a totally different view and have no possibility to "add" anything.
  • Evan Leis
    Evan Leis about 10 years
    This answer is invalid in Android Studio 0.4.5
  • Eugen Martynov
    Eugen Martynov about 10 years
    Sorry, I can not find way how enter dependencies now
  • Imanol
    Imanol about 10 years
    @EvanLeis You can still click use the second method to add sources in Android Studio 0.4.5
  • Moritz
    Moritz almost 10 years
    The proposed solution from the editor does not work when attaching javadoc.
  • AndroidGecko
    AndroidGecko almost 10 years
    any solution for attaching javadoc folder as of 0.6? its really annoying
  • Eugen Martynov
    Eugen Martynov almost 10 years
    I'm usually attaching sources. All good libraries are shipped in maven with sources. This gives me ability to debug even and read javadoc for method if I want
  • Wooff
    Wooff almost 10 years
    Is it really needed to attach sources manually? IDE's dependency manager should know better than user which sources/version is actually used for specific project. So, which javadoc/source should be attached.
  • Eugen Martynov
    Eugen Martynov almost 10 years
    Yeah, I meant that I usually ask IDE to download sources
  • cprcrack
    cprcrack over 9 years
    +1 because it works, but not being able to sync with gradle files is far from perfect
  • Toochka
    Toochka over 8 years
    +1 (as per above comment) because it works -1 because its a hack :) Google saddens me and it's not a first time
  • Radu Cugut
    Radu Cugut about 8 years
    this is the best answer for the question
  • nasch
    nasch about 8 years
    That's only for the android platform, this question is about other libraries.
  • bobasti
    bobasti almost 7 years
    +1 it worked for me. I exported a .jar file with resources (source code, javadoc) and just added the same snipped for CLASSES, JAVADOC and SOURCES: <root url="jar://$PROJECT_DIR$/app/libs/LibraryName.jar!/" />
  • Admin
    Admin almost 7 years
    The linked project is now deprecated as this functionality is built into Android Studio 1.4+.
  • JensV
    JensV almost 7 years
    This only works with maven attached libraries though
  • beyeriii
    beyeriii over 6 years
    Verified this solution works in Android Studio 3.0.1
  • tir38
    tir38 about 6 years
    @JensV see Robyer 's answer for how to use this with local .jar
  • demaksee
    demaksee almost 6 years
    I found this hint about "Project" + "Structure" tabs at the same time very very useful. And not only for adding javadoc for local library, but also, because "Structure" shows Module Dependencies, and we have project with two dozens of modules.
  • ccpizza
    ccpizza about 5 years
    This might enable javadoc for JavaSE (if the JDK comes with javadoc/source) but not for android SDK.
  • DarkNeuron
    DarkNeuron over 3 years
    I have a zip file with the javadocs for a .jar, but Android Studio 4.1 doesn't show any documentation for any classes/methods. Did something change?
  • Robyer
    Robyer over 3 years
    @DarkNeuron Try extracting the ZIP somewhere and linking to that folder or using JAR file instead of ZIP file for the docs, as I just found this old post: intellij-support.jetbrains.com/hc/en-us/community/posts/… (maybe it's not really related, but may be worth try)
  • DarkNeuron
    DarkNeuron over 3 years
    @Robyer Thanks, already tried that; sadly it didn't work. :( Maybe Android Studio is just buggy regarding this use case.