29

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?

1

3 Answers 3

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!

7
  • 1
    and how to reference an XML file? something like {@link res/custom_strings.xml}
    – rexxar
    Dec 20, 2016 at 9: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 2, 2017 at 19:24
  • 1
    Thank you for your words of understanding and encouragement! Here it is: stackoverflow.com/questions/41433645/…
    – rexxar
    Jan 2, 2017 at 21:43
  • Any chances you would know how to link build.gradle file in comments? Mar 23, 2018 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, 2018 at 5:40
23

The format for the javaDoc lint tag in Android Studio is:

{@link package.class#member label}

Here is more information on javaDoc tags.

2
  • 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. Apr 30, 2016 at 16:54
  • Any chances you would know how to link build.gradle file in comments? Mar 23, 2018 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.

1
  • this is very important for someone who is new to documentation in Android Studio, as for Android Studio will not recognize @link command... Dec 14, 2020 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.