How to use Android SDK Documentation offline

﹥>﹥吖頭↗ 提交于 2019-12-18 10:26:24

问题


I've downloaded Android SDK Documentation using SDK Manager, to use it with Android Studio v2.3.0.8, offline.

But everytime I press ctrl+q to show quick info about a type|type-member, it shows "Fetching Documentation...", and after waiting for ~20s, it shows the info.

I don't want that delay or using online help, and the local docs are in place, so why is that ? And what is the solution ?

Edit: This happens when I'm online, but no delay at all when I'm offline, As if the IDE tries to get a fresh version of docs.


回答1:


Improved solution for displaying documentation (from sources).

Found, that if you download documentation via SDK manager (it will be located in .../sdk/docs/reference), you're going to use only 24 API documentation. (Imagine, your project target SDK is 25 or 22, for instance).

To fix this, you need:

  1. Delete documentation via SDK manager in Android Studio.
  2. Right there, download sources for interested APIs (sources already contain documentation). Also I found, that fetching documentation from sources a bit faster comparing with offline one inside .../sdk/docs/reference.
  3. Delete all javadoc paths from jdk.table.xml. Path to this file on OS X: /Users/.../Library/Preferences/AndroidStudio.../options/jdk.table.xml

    --> Delete all of these and all occurrences -->
    
    <javadocPath>
      <root type="composite">
        <root type="simple" url="http://developer.android.com/reference/" />
      </root>
    </javadocPath>
    
  4. Reboot Studio. Enjoy!



回答2:


I downloaded it too, and I noticed that the Android Studio didn't generated the javadocPath properly in jdk.table.xml, that's how the file looks like (part that has the jdk tag with the name Android API ## Platform):

...
<jdk version="2">
  <name value="Android API 25 Platform" />
  <type value="Android SDK" />
  <homePath value="$USER_HOME$/android-sdk" />
  <roots>
      ...
    <javadocPath>
      <root type="composite">
        <root type="simple" url="http://developer.android.com/reference/" />
      </root>
    </javadocPath>
      ...

File is located at Android Studio Configuration folder/config/options/jdk.table.xml

Notice that the javadocPath is pointing to the online url, just change that to your local copy, in my case, the docs folder is in /home/mauricio/android-sdk/docs, in Windows is something like C:/android-sdk/docs.

The url structure that you have to follow is file://<path-to-sdk>/docs/reference

You have to point to the reference folder inside the docs.

It'll look something like this:

  <root type="simple" url="file:///home/mauricio/android-sdk/docs/reference" />
  <!-- if it's Windows -->
  <root type="simple" url="file://C:/android-sdk/docs/reference" />

Then, if it's running, restart the Android Studio and it's done.
I have a SSD too, and the offline documentation makes it open instantly.

Note: You have to do that in all javadocPath in the file (pretty easy using Replace all in any text editor), and when you download a new Android API, you have to do that again because it generates the url pointing to the online docs.


I think this is a bug in Android Studio, because the sourcePath and classPath is detected and generated correctly. It's worth reporting to them.




回答3:


One way to fix config/options/jdk.table.xml is to stop the IDE, delete the file, ad restart. The IDE finds the installed SDKs, and it regenerates the options file.

I had issues with an upgrade from a preview release to 3.2 and docs were slow to display, and the above fixed the issue.




回答4:


For sdk tools v26, using the command-line:

PATH_TO_SDK/tools/bin/sdkmanager "docs"

Then go to the directory PATH_TO_SDK/docs and open index.html file.



来源:https://stackoverflow.com/questions/42893969/how-to-use-android-sdk-documentation-offline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!