I'm trying to generate some Javadocs with Android Studio. I'm referring with {@link #method()}
a method in the same class as the link but I still get a reference not found
error from Javadoc. I'm probably omitting something very stupid but I cannot figure out what it is. Has anybody else come across the same problem?
Asked
Active
Viewed 2.5k times
29
-
2A bug report has been filed - seems to be a similar - though it is related to auto-complete but you might get some additional info there: https://code.google.com/p/android/issues/detail?id=67855 – AgentKnopf Feb 16 '15 at 10:08
3 Answers
46
In Android Studio within a javadoc comment, try typing {@
and then hitting ctrl+space to see what pops up...
After choosing link
, hit space.
Now try ctrl+space again for a list of all possible classes.
To just make a reference to a method/data within the current class, type # and then ctrl+space to see a list of probably-what-you-want.
Don't forget to make sure the brackets are closed!

SMBiggs
- 11,034
- 6
- 68
- 83
-
1and how to reference an XML file? something like `{@link res/custom_strings.xml}` – rexxar Dec 20 '16 at 09:52
-
1@Rexxar: Don't know, but that's a very good question! Go ahead and make it a separate question and post the link here for others. – SMBiggs Jan 02 '17 at 19:24
-
1Thank you for your words of understanding and encouragement! Here it is: http://stackoverflow.com/questions/41433645/how-to-reference-an-xml-file-in-android-javadoc – rexxar Jan 02 '17 at 21:43
-
Any chances you would know how to link build.gradle file in comments? – Rahul Khurana Mar 23 '18 at 11:44
-
@RahulKhurana That's a really good question! You should make your own question. That way other people can easily find it. – SMBiggs Mar 24 '18 at 05:40
-
thanks @ScottBiggs i did posted a new question [here](https://stackoverflow.com/q/49483931/4079010). Let me know if you figure out a way to link gradle file in the post. – Rahul Khurana Mar 26 '18 at 04:22
-
for XML layout = {@link R.layout#activity_main}, drawable {@link R.drawable#ic_television} and so on. – Soon Santos Aug 01 '18 at 13:32
23
The format for the javaDoc lint tag in Android Studio is:
{@link package.class#member label}
Here is more information on javaDoc tags.

Nathaniel Ford
- 20,545
- 20
- 91
- 102

Richard Goggin
- 331
- 2
- 4
-
because it doesn't fix the problem why these show up. long explanation is that when you extend a view and override methods in android studio and choose to add the javadoc for the overridden methods then the links in them don't include the package name in the link. and android studio drows a fit over it and you have to manually fix them with some search & replace. so for example see android.view.View#View(Context, AttributeSet, int, int) is imported into your view extending class as see #View(Context, AttributeSet, int, int), and you need to fix manually. – Lassi Kinnunen Apr 30 '16 at 16:54
-
Any chances you would know how to link build.gradle file in comments? – Rahul Khurana Mar 23 '18 at 11:44
13
I don't know if anyone is still struggling with it but if you are and {@link
is not working then make sure your comment block looks something like this
/**
* {@link 'your reference'
*/
make sure that the comment block starts with two *
and not one, apparently, this works for me in the android studio.
-
this is very important for someone who is new to documentation in Android Studio, as for Android Studio will not recognize @link command... – Nikhil Sharma Dec 14 '20 at 12:53