user7736965
user7736965

Reputation:

How to use Android SDK Documentation offline

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.

Upvotes: 35

Views: 31729

Answers (5)

peerless2012
peerless2012

Reputation: 209

You can download the offline docs on Android SDK Offline

Then unzip the tar folder Android.docset/Contents/Resources/Documents/developer.android.com to sdk/docs.

Then you can use the offline docs in AndroidStudio, but there is a little bug, the style of web is not right.

Upvotes: 0

oxied
oxied

Reputation: 1908

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).

Only 24 API in downloaded documentation

To fix this, you need:

  1. Delete documentation via SDK manager in Android Studio. Delete documenattion in SDK manager
  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. Download sources via SDK manager for interested APIs
  3. Delete all javadoc paths from jdk.table.xml. Path to this file on OS X: ~/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!

Upvotes: 45

Mike Hanafey
Mike Hanafey

Reputation: 5643

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.

Upvotes: 3

OMar Mohamed
OMar Mohamed

Reputation: 333

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.

Upvotes: 2

Mauricio
Mauricio

Reputation: 181

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.

Upvotes: 18

Related Questions