Android Studio quick documentation always "fetching documentation"
Asked Answered
T

13

107

I just moved to Android Studio from Eclipse, and I found that it always shows "fetching documentation" when I use quick documentation (Ctrl+Q).

How can I solve this problem? I downloaded the documentation for API 19, and the problem persists.

enter image description here

Task answered 30/4, 2014 at 2:22 Comment(6)
I have the same issue ! Version 0.5.2Hiramhirasuna
Me too. I have v0.8. Anyone have a solution?Destruct
When the Internet connection is switched off (Wifi off), it runs much more quickly.Respectively
In my case I just didn't download it: https://mcmap.net/q/205188/-no-reference-documentation-in-android-studioSinner
Can you set this as the accepted answer? It's the official way to do it and super easy: https://mcmap.net/q/203033/-android-studio-quick-documentation-always-quot-fetching-documentation-quotAnapest
This answer here works in 2021 https://mcmap.net/q/203033/-android-studio-quick-documentation-always-quot-fetching-documentation-quotJanniejanos
I
128

The problem is Android Studio does not automatically update the source link of reference even when the documentation is already downloaded.

The default link in jdk.table.xml is http://developer.android.com/reference/ (android studio tries to connect to this online server even if the network is blocked).

To solve the problem, we can just redirect the reference to local source.

MacOS

On MacOS, the config file jdk.table.xml is under ~/Library/Preferences/AndroidStudio<version>/options/, and the docs are here: ~/Library/Android/sdk/docs/, or the custom path of your Android SDK.

In jdk.table.xml, find all the lines:

<root type="simple" url="http://developer.android.com/reference/">

and modify them to

<root type="simple" url="file://$USER_HOME$/Library/Android/sdk/docs/reference/">

Windows

On Windows, the file jdk.table.xml is under C:\Users\Name\.AndroidStudio<version>\config\options

In AndroidStudio 3.3, modify to

<root type="simple" url="file://$USER_HOME$/AppData/Local/Android/sdk/docs/reference"  />

Android Studio (any os)

Then, in File -> Invalidate Caches / Restart… select Invalidate, and retry using Quick Documentation. It should display instantly. If it doesn't, select Invalidate and Restart, and you should be good to go.

Irrelevancy answered 18/11, 2015 at 3:23 Comment(12)
Thank you - this really helped me.Destruct
Worked with AS 2.3 canary 3.Dooryard
Should be the accepted answer, it worked very well on Android Studio 2.3 on MacOSWhitebook
Does anyone have the issue that the http links are added back constantly? Have to do it repeatedly.Jakejakes
Worked with android studio 3.0 :)Snoddy
@Jakejakes I have the same problem... How do we make it permanent?Victory
@Victory unfortunately I have not yet found the solution. What I am doing is to manually delete them again and again and restart Android Studio. :(Jakejakes
htea 1 - Google 0Sake
@Jakejakes The some problem. I am obligated to correct (copy-paste) the problem constantly.Samba
Is it actually best to rename all those XML elements? I have followed the above steps and I now have 24 sibling rows of <root type="simple" url="file://$USER_HOME$/AppData/Local/Android/sdk/docs/reference" /> in my in C:\Users\MY_USERNAME\.AndroidStudio3.0\config\options\jdk.table.xml file. Wouldn't just one of these rows be enough instead??Horst
Note: It's essential to replace all the <javadocPath> with something like url="file://$USER_HOME$/Library/Android/sdk/docs/reference/" even if "docs/reference/" does not exist in your Android SDK folder. It will somehow still work.Respectively
In Linux, you can find it here: $HOME/.AndroidStudioPreview3.2/config/options (replacing .AndroidStudioPreview3.2 with the IDE variant that you are using)Concomitant
K
51

Update:

On the newest Android Studio versions you can do as following:

  1. Navigate to Tools > SDK Manager
  2. Select the SDK Platforms tab
  3. Make sure the Show Package Details checkbox, at the bottom right, is checked.
  4. Select your target API level from the list, check the Sources for Android [API_Level] and click apply.

For older Android Studio versions:

Go to: Tools > Android > SDK Manager. Select SDK Tools tab and:

  1. if Documentation for Android SDK is unchecked, check it and click apply
  2. If Documentation for Android SDK is checked, uncheck it and click apply. After uninstall completes check it again and click apply.
Krefeld answered 12/4, 2017 at 6:39 Comment(5)
Trying it out... funny thing, I uninstalled the docs, disabled network adapters, and hit Ctrl+Q inside the AS ... got "fetching documentation" of about 0.5s, then the documentation for some Android class popped up. No idea, where it got it from. Now I'm installing the Doc package back, hoping it will fix the fetch times, thank you for idea.Interlunar
@Jakejakes you are using probably antivirus SW? Took about 30min on corporate win7 with AV, but under 1min at home with linux. In the end it partially works for me, the fetch times went down a lot, but it still feels like not completely off-line, like there's some tiny ping going on, and the AS is hesitating for 200-600ms before showing the offline version (but part of that time is probably actual fetch, it's from that win7 machine, which is overall sluggish when compared to my main linux machine, looks like the price of running primitive OS). Anyway, this answer should have WARNING. :)Interlunar
Finally I see an android documentation that makes sense.Pudendas
After A.S. re-install, Documentation for Android SDK got unchecked for some reason. Thanks!Afterbody
For Android Studio BumbleBee 2021.1.1 there's no "Documentation for Android SDK" anymore on the "SDK Tools" tab, but I checked "Sources for Android <SDK level>" on the "SDK Platforms" tab and it worked. That option is only visible when you check the "Show Package Details" checkbox. Hope it helps someone.Doughy
O
30

UPDATE: out-of-date, please check @Htea's answer.

I was having the same issue as you. Here's what fixed it for me:

  • Make sure you have the Documentation package downloaded in SDK Manager.
  • Exit Studio if it's running.
  • Delete the file named "jdk.table.xml" located in ~/.AndroidStudioX.Y/config/options/ (remember to take a backup first!).
  • Relaunch Android Studio. should work correctly now and it should regenerate the file automatically.

Note:

  • This worked for me on Ubuntu 14.04 & Android Studio 0.8.11 (EDIT: Several users are reporting this solution also works for newer versions of Android Studio).
  • If it still doesn't work, try deleting and re-downloading the Documentation package from inside Android SDK Manager then try the above steps.
  • If you're running Windows, the file is located at "%UserProfile%.AndroidStudio\config\options", and if you're running OS X, it's located at "~/Library/Preferences/AndroidStudio/options" (credits to @Gero and @Alex Lipov).

Hope it helps.

Oraleeoralia answered 1/10, 2014 at 19:28 Comment(9)
Also works on Windows 7, the file is located at "%UserProfile%\.AndroidStudioBeta\config\options". BTW, the Documentation package is under the LATEST Api level group of SDK Manager.Putput
Works fine, thanks! On Mac, the mentioned file located under ~/Library/Preferences/AndroidStudioBeta/optionsMiddleoftheroad
Works for me. Thanks! Just a note: as of Android Studio 1.0, the folder is .AndroidStudio (no Beta in the name).Joost
Works with Ubuntu 16.04 and AS 2.1.2Reis
Fixed my issue on AS 2.2 Beta 3 and Ubuntu 16.04Allegro
When using this solution with Android Studio 2.3 it asked me for my SDK's location at next launch. I recommend using Htea's solution instead which really fixes the problem without side effects.Pyuria
I recommend Htea's solution below. Doesn't work on studio 2.3.3. Interestingly I had to make changes in both folders:.AndroidStudio2.3 and .AndroidStudioPreview2.0Gambia
Works on Windows 10 running Android Studio 3.0Aggressor
Fixed my issues on Android Studio 3.1.3 @windows7Domineer
P
23

The reason for me was that I had not downloaded sources for my SDK version defined by compileSdkVersion property in the build file (now called compileSdk in AGP 7.0.0).

So, in Android Studio 4.0 and higher do this:

Go to Settings 🡲 Android SDK 🡲 SDK Platforms tab 🡲 select Show Package Details checkbox at the bottom 🡲 under your target API Android section check the Sources for Android xx 🡲 click Ok and wait for the download to finish.

The image showing how to do this

Thanks to Cyn45 for their answer.

Parchment answered 14/4, 2021 at 8:16 Comment(3)
Thank you! All the other answers here are out of date at this point. Didn't even need to invalidate/restart.Adele
Thanks! Other answers are outdated indeed.Robbegrillet
Updated for 2022. If anyone is still unable to find in Tools, remember to check "show package details" at the bottom right of the screen.Surd
M
12

As other answers said, it's because the Android Studio is trying to fetch the javadoc online (from http://developer.android.com/reference/), which will be very slow if the network not good, especially in China because google is blocked. So we should change this setting and let Android Studio fetch javadoc locally:

  1. Download Android SDK Documentation using the Android SDK Manager.
  2. Open the file ~/Library/Preferences/AndroidStudio2.2/options/jdk.table.xml, see notes below to make sure the correct file is edited.
  3. In the file jdk.table.xml, replace all http://developer.android.com/reference/ to the path to your sdk reference folder. For example file://$USER_HOME$/tools/adt-bundle-mac/sdk/docs/reference on my Mac.

On OS X, if you have used several versions of Android Studio, there may be several configuration folders for each version (under ~/Library/Preferences/), you should change the jdk.table.xml in the right folder, in my case I should edit jdk.table.xml under the folder AndroidStudio2.2.

OS X screenshot

Meekins answered 27/9, 2016 at 6:52 Comment(1)
It's important to use the "sdk/docs/reference/" path even if the sources are stored in "sdk/sources/android-26/" on your computer. It will somehow work.Respectively
G
11

On Windows

File location of jdk.table.xml

C:\Users\[your windows user name]\.AndroidStudio2.3\config\options\jdk.table.xml

Notes

  • "." before AndroidStudio directory
  • version number after ".AndroidStudio". Be sure to edit the version number of Android Studio you're currently using. Previous versions will still have directories here as well.

Line to edit

Before

<root type="simple" url="http://developer.android.com/reference/" />

After

<root type="simple" url="file://C:/Android/sdk/docs/reference" />

Notes

  • C:/Android/sdk/docs/reference replace with Android SDK location on your machine
  • if you're copy/pasting location from File Explorer, replace backslashes (\) with forward slashes (/)
  • Each installed Android SDK version will have its own docs XML entry
  • Edit the line above in each SDK version found in jdk.table.xml (if you want quick docs when targeting those versions in build.gradle). e.g. If you have Android SDK API 25 installed, you'd find a section to edit under <name value="Android API 25 Platform" />

Invalidate Caches / Restart after change!

File -> Invalidate Caches / Restart...

Ginetteginevra answered 23/5, 2017 at 18:27 Comment(0)
E
5

I also found this issue with Android studio 0.8.9 & 0.8.14, here's a simple solution:

File -> Invalid Caches/Restart -> Invalidate and Restart


Sometimes the documentation package may be missing or not up-to-date.

Try open the Android SDK manager(Tool->Android->SDK Manager) and install the 'Documentation for Android SDK' in the latest release, for now it's Android 5.0(API 21), then restart Android studio.

If this happens again, just invalidate the caches.

Emlynne answered 1/12, 2014 at 9:10 Comment(0)
A
5

For android studio 3.4, all you need to do is go to sdk manager -> SDK Tools, check "Documentation for Android SDK" and click apply.

It will automatically update the jdk.table.xml to point to the source you have downloaded.

Ardithardme answered 23/8, 2019 at 2:41 Comment(5)
That was it. Thanks a lot !Amalita
Simple and works. This answer should has more vote.Toratorah
I don't see this option in Android Studio 4.0. Of course (I think google thinks that change is better than consistency--or even better than functionality).Leonelleonelle
This checkbox is not avaliable for me.Cimabue
There is "Sources for Android x" checkbox, available for each API, displayed under "SDK Tools" tab when you also check "Show Package Details" checkbox at the bottom right corner. It looks like it downloads the documentation.Remark
T
1

I found a solution.

  1. Close the android studio and delete the c:\Users\xxx.AndroidStudioBeta\ (in my case)
  2. Change the android sdk path name
  3. Open the android studio, it will ask for the sdk path

Now you can change back the sdk path or using the new sdk path.

You will find Ctrl+Q will work fine. (Don't import old setting)

I think we need download the sdk document before set the sdk path to Android studio. But the Android studio should handle this case or give us a option to set it.

Tarsus answered 31/7, 2014 at 7:24 Comment(0)
P
1

For a quick workaround edit /etc/hosts (or C:\Windows\System32\Drivers\etc\hosts) file and add the line:

0.0.0.0 developer.android.com

This will prevent it but you can comment it out when you need to fetch the latest or ones not cached or read the docs online.

Picofarad answered 16/2, 2019 at 16:1 Comment(0)
S
0

UPDATE: From unknown exactly version, just simply download Android Documentation in SDK Manager could fix the problem. My 3.4.1 do so.

But I don't know whether older version could works as well or not.

Separation answered 12/6, 2019 at 13:28 Comment(0)
V
-1

I meet the same issue too,but I solved it just now. I used the Android Studio with SDK before I solved it,and then I download a Android Studio Zip without SDK,and run it,and the issue disappeared. You can try it.

Vanpelt answered 29/9, 2014 at 12:50 Comment(0)
C
-1

you can disable it, in Android Studio Preference

Android Studio -> Preference -> Editor -> General -> Code Completion -> Show the documentation pupup in XX ms

enter image description here

see my another answer Link

Carranza answered 4/4, 2019 at 6:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.