Android Studio: how to connect javadoc

This may be a very trivial question, but I could not find any javadoc / source connection option with local jar dependencies (in the libs folder) in the android project. I canโ€™t believe that I spent an hour on such simple things :(

The Google search result just talks about adding Android documentation and adding javadoc to eclipse. This is not what I'm looking for!

+54
intellij-idea android-studio gradle
Jan 08 '14 at 11:27
source share
10 answers

I have found a solution just now, since I cannot find any other solution for a long time.

suppose:

  • your lib name: libxxx.jar
  • Javadoc name is docs.zip

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

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

then ctrl + alt + y to synchronize the project. (Do not execute "Sync project with Gradle files", it will delete the changes)

+33
Aug 22 '14 at 2:26
source share

I found and tested the way we can add javadocs without losing them after gradle synchronization.

  • Right-click Project Panel > External Libraries > libname
  • Click Library Properties . Lib props
  • Click the documentation URL link
  • And provide the url. For my machine, it was file:///opt/android-sdk/extras/google/google_play_services/docs/reference Add doc url
  • Result: added jdoc
  • And after synchronizing the project, I could view the javadoc of Google Play services google play services maps javadoc

Note:

This put the same JAVADOC entry in xml identified by Jason , but does not disappear after synchronizing with gradle

+22
Jan 11 '16 at 12:31 on
source share

Maybe:

  • Open Project structure
  • Go to the dependency you want
  • Click the button from the screenshot and specify the folder or file.

screenshot 1

Another way to connect sources:

  • Step into the class from the library (hover over the class name and do CMD + left click or CMD + B)
  • You will see a decompiled version of the class there menu in the upper right part of the "Attach sources .." editor

screenshot 2

+17
Jan 08 '14 at 2:30
source share

The issue with my post is still relevant:

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

+2
Jan 07 '15 at 2:18
source share

I had a problem with the answer from Matyas that I did not see my local .jar library in the External Libraries list because it only shows maven sub libraries.

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

  • Right-click on the Structure tab and select Split Mode (to open the Project and Structure tabs at the same time).
  • Open the Project and Structure tabs at the same time.
  • On the Project tab, select the Android perspective, and then select your moduleโ€™s folder (for example, โ€œapplicationโ€).
  • In the Structure window, you should see a list of all libraries, including the local * .jar

Continue as in response from Matyas:

  1. Right-click the desired library and select "Library Properties ..."
  2. If you have * .jar with javadocs locally, you can click the Add button (green "+") and find the file on your disk (you do not need to type the path "file: //" manually).
+2
Apr 12 '17 at 4:43 on
source share

After some investigation, I came across this:

https://github.com/xujiaao/AARLinkSources

It works like magic!

+1
Apr 14 '15 at 1:18
source share

I spent so much time on this too ...

Here's the gradle task, which finds the source code and javadoc by location / name agreement and registers them in .idea files during synchronization. It belongs to the root file allProjects gradle. As-is, it expects to find [projectname] /libs/lib.jar next to lib-sources.jar and / or lib-javadoc.jar . In addition, as noted in the comments, if your javadocs were not placed in the "/" inside the jar, you may need to modify the script to add "docs / html" (for example) at the end of the "jar: // $ dock! /" .

 allprojects { task addJavaDoc { afterEvaluate { // Specify paths, this will be run per non-root project def projectDir = project.getProjectDir().getCanonicalPath() def rootDir = project.getRootDir().getCanonicalPath() def lib = projectDir + '/libs' // println lib // Uncomment this to troubleshoot // Get any jar dependencies register in the lib folder fileTree(include: ['*.jar'], exclude: ['*-source.jar', '*-javadoc.jar'], dir: lib ).each { File jar -> def jarName = jar.getName() def moduleName = jarName.substring(0, jarName.lastIndexOf(".")) // IntelliJ does this to file names when making the xml files def escapedName = moduleName.replace("-", "_").replace(".", "_") def xmlFile = "$rootDir/.idea/libraries/${escapedName}.xml" // println xmlFile // Uncomment this to troubleshoot if (new File(xmlFile).exists()) { ['javadoc', 'sources'].each {String docType -> // Get sources or java doc by naming convention, (expects name-sources or name-javadoc def doc = "$lib/$moduleName-${docType}.jar" // println doc // Uncomment this to troubleshoot if(new File(doc).exists()) { def xml = new XmlParser().parse(xmlFile); def xmlTag = docType.toUpperCase() // Perform xml replacement by convention xml.library[xmlTag].replaceNode { "$xmlTag" { root(url: "jar://$doc!/") } } // Write out changes new XmlNodePrinter(new PrintWriter(new FileWriter(xmlFile))).print(xml) // Notify that changes worked println "Fixed up reference to $doc" } } } } } } } 

Also, if you use jcenter or mavencentral, javadocs and sources should work for downloaded jars without using this task, but you may have to add this to every file without root gradle:

 apply plugin: 'idea' idea{ module { downloadJavadoc = true downloadSources = true } } 
+1
Apr 27 '17 at 6:49
source share

There is a solution, this procedure is performed through the terminal,

I tested the solution on MAC OS .

1) Go to the project folder

2) ls -al (to display hidden files)

3) Go to the .idea folder, Command: cd.idea

4) Navigate to the libraries folder, Command: cd libraries /

5) Now you can view a list of all xml files for your libraries or banners. Edit it as vi open androidasync_2_1_7.xml

6) On the editor screen, to insert

 Press i 

Now you see the <SOURCES /> , which we must specify here, for example,

 <SOURCES> <root url="file://$PROJECT_DIR$/androidasync/src/main/java" /> </SOURCES> 

To exit

 Press Esc :wq //for exiting and saving :q! //for exiting without saving 

7) Restart Android studio (gradle synchronization is sometimes required).

0
Jun 10 '16 at 6:28
source share

Personally tested successfully!

1. Project structure (ctrl + alt + shift + s)

2.SDK Location

3.JDK Location

4.UnCheck "Use the built-in JDK (recommended)"

5.Select your own jdk path (My path: C: \ Program Files \ Java \ jdk1.8.0_111)

6.Synchronized (Ctrl + Alt + y)

success

0
Jan 21 '17 at 16:09 on
source share

in android studio, if you use compileSdkVersion 23 in buidl.gradle and you have loaded the document file and the source SDK 23 file in the SDK manager , the android API and java API doc and the source will be displayed automatically, you do not need manual dialing.

-one
Sep 06 '15 at 9:13
source share



All Articles