Android Studio: How to attach javadoc
Solution 1
I found a solution just now since I can't find any other solution for a long time.
suppose:
- your lib name is: libxxx.jar
- 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.
- Right click in Project panel > External libraries > lib-name
- Click Library properties
- Click specify documentation URL
- And specify an URL. For my machine it was
file:///opt/android-sdk/extras/google/google_play_services/docs/reference
- The result was:
- And after a project sync I could browse the javadoc of the google play services
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:
- Open
Project structure
- Navigate to dependency that you want
- Press button from the screenshot and provide folder or file
Another way to attach sources:
- Step into class from library (Hover mouse over class name and do CMD + Left click or CMD + B)
- You will see decompiled version of class there menu on the top right side of editor "Attach sources.."
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
- Right click on the "Structure" tab and check "Split Mode" (so you can open both "Project" and "Structure" tabs at same time).
- Open both "Project" and "Structure" tabs at the same time.
- In "Project" tab select "Android" perspective and then select your module folder (e.g. "app")
- In "Structure" window you should now see list of all libraries, including your local *.jar
Continue as in answer from Matyas:
- Right click on wanted library and select "Library Properties..."
- 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:
Ashish Bindal
Updated on April 27, 2020Comments
-
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 over 10 yearsThat'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 over 10 years@ScottBarta Yeah, sources are not persisted. Is there any workaround?
-
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 about 10 yearsThis answer is invalid in Android Studio 0.4.5
-
Eugen Martynov about 10 yearsSorry, I can not find way how enter dependencies now
-
Imanol about 10 years@EvanLeis You can still click use the second method to add sources in Android Studio 0.4.5
-
Moritz almost 10 yearsThe proposed solution from the editor does not work when attaching javadoc.
-
AndroidGecko almost 10 yearsany solution for attaching javadoc folder as of 0.6? its really annoying
-
Eugen Martynov almost 10 yearsI'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 almost 10 yearsIs 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 almost 10 yearsYeah, I meant that I usually ask IDE to download sources
-
cprcrack over 9 years+1 because it works, but not being able to sync with gradle files is far from perfect
-
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 about 8 yearsthis is the best answer for the question
-
nasch about 8 yearsThat's only for the android platform, this question is about other libraries.
-
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 almost 7 yearsThe linked project is now deprecated as this functionality is built into Android Studio 1.4+.
-
JensV almost 7 yearsThis only works with maven attached libraries though
-
beyeriii over 6 yearsVerified this solution works in Android Studio 3.0.1
-
tir38 about 6 years@JensV see Robyer 's answer for how to use this with local .jar
-
demaksee almost 6 yearsI 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 about 5 yearsThis might enable javadoc for JavaSE (if the JDK comes with javadoc/source) but not for android SDK.
-
DarkNeuron over 3 yearsI 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 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 over 3 years@Robyer Thanks, already tried that; sadly it didn't work. :( Maybe Android Studio is just buggy regarding this use case.