Generate Javadoc error Android Studio
Asked Answered
C

6

20

For some reason I cannot generate a javadoc with Android Studio, after like 96 warnings it gives me this:

95 warnings
java.lang.NullPointerException
at com.sun.tools.javadoc.TypeMaker.getType(TypeMaker.java:83)
at com.sun.tools.javadoc.TypeMaker.getType(TypeMaker.java:44)
at com.sun.tools.javadoc.ClassDocImpl.superclassType(ClassDocImpl.java:496)
at com.sun.tools.doclets.internal.toolkit.util.Util.getAllInterfaces(Util.java:453)
at com.sun.tools.doclets.internal.toolkit.util.Util.getAllInterfaces(Util.java:491)
at com.sun.tools.doclets.internal.toolkit.util.ClassTree.processType(ClassTree.java:194)
at com.sun.tools.doclets.internal.toolkit.util.ClassTree.buildTree(ClassTree.java:146)
at com.sun.tools.doclets.internal.toolkit.util.ClassTree.<init>(ClassTree.java:91)
at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:123)
at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:83)
at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:63)
at com.sun.tools.doclets.standard.Standard.start(Standard.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:280)
at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:160)
at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:397)
at com.sun.tools.javadoc.Start.begin(Start.java:167)
at com.sun.tools.javadoc.Main.execute(Main.java:59)
at com.sun.tools.javadoc.Main.main(Main.java:49)

javadoc exited with exit code 1

Is there a way to create the javadoc in android studio? If not, how could i create one, I need to give it with my project.

Cockswain answered 18/6, 2014 at 22:48 Comment(1)
I suppose that in 2014 there was no Javadoc UI in Android Studio, right?Talc
C
11

Adding the following line on "other command line arguments" fixed the errors:

-bootclasspath /path/to/sdk/platforms/android-##/android.jar

Cockswain answered 19/6, 2014 at 1:11 Comment(4)
I had 4 errors (but some content was generated, though), using this fixed them. Thanks!Lorrianelorrie
Still getting following error: "Constructing Javadoc information... com.sun.tools.javac.util.FatalError: Fatal Error: Unable to find package java.lang in classpath or bootclasspath 1 error"Bonne
@Bonne Then, id suggest you to start a question where you explain that you have tried this and show the error you are still getting, you will probably get more feedback that way. Good luck!Cockswain
With new java versions, -bootclasspath is not allowed. Used -sourcepath instead.Pyromancy
G
33

A combination of the two answers given here worked well for me. Though the docs generate fine, I still get 900 warnings and 140 errors BUT they're all related to the android packages. This is just the given solutions combined and explained a bit for people who aren't familiar with Android Studio or command line interfaces.

HOW TO GENERATE JAVADOC IN ANDROID STUDIO

  1. Open Android Studio > Tools > Generate Javadoc
  2. Select the scope, usually the whole project
  3. Check include jdk and library sources
  4. Specify the output directory. A load of files will be dumped here, so I recommend creating a new folder.
  5. Select which methods you want to expose. Usually protected is desirable unless it has to look impressive for school.

The "tricky" part, "Other command line arguments". Under the pretty GUI, there's a direct call to the javadoc command, which runs the javadoc generator. The command line uses a structure like this: program_name [-flag] argument [-flag] argument, which as you can guess calls the program with certain optional behaviours, passing in what those should be.

So by specifying the following under "Other command line arguments"

  1. -encoding utf-8 -bootclasspath /path/to/sdk/platforms/android-##/android.jar followed by clicking OK

you're really calling the javadoc program with these flags and arguments. These two flags allow the javadoc program to ignore unicode characters and find the android.jar though it seems that everything marked with # is read as a number and the android javadocs are filled with them.

I urge you to read through the warnings for your classes despite the seemingly large amount of spam, as javadoc will tell you when you've forgotten things like empty @return statements.

Gonorrhea answered 14/1, 2015 at 9:43 Comment(0)
C
11

Adding the following line on "other command line arguments" fixed the errors:

-bootclasspath /path/to/sdk/platforms/android-##/android.jar

Cockswain answered 19/6, 2014 at 1:11 Comment(4)
I had 4 errors (but some content was generated, though), using this fixed them. Thanks!Lorrianelorrie
Still getting following error: "Constructing Javadoc information... com.sun.tools.javac.util.FatalError: Fatal Error: Unable to find package java.lang in classpath or bootclasspath 1 error"Bonne
@Bonne Then, id suggest you to start a question where you explain that you have tried this and show the error you are still getting, you will probably get more feedback that way. Good luck!Cockswain
With new java versions, -bootclasspath is not allowed. Used -sourcepath instead.Pyromancy
D
2

I don't think this issue is specific to Android Studio. I'm guessing it will happen anytime you've got Unicode characters in your JavaDoc comments.

Try using the following command:

javadoc -encoding utf-8

Alternatively, you can just use Unicode escapes (e.g. \u0000) instead of including Unicode characters directly.

In Eclipse, you can add extras to the JavaDoc command:

Project -> Generate Javadoc -> Next -> on the last page, in Extra Javadoc options write:

-encoding UTF-8
Diplex answered 18/6, 2014 at 23:2 Comment(12)
where do I put that at? And yes it must be that because I have accents and all that paraphernalia in my commentsCockswain
I mean, I just use the Tools -> Generate Javadoc thingCockswain
I supose you mean "other command line arguments" in android studio when i'm going to create it, and well the -encoding UTF-8 thing didn't work, same errors :(Cockswain
Try -encoding UTF-8 -charset UTF-8 -docencoding UTF-8Diplex
with "javadoc" infront of each?Cockswain
don't put javadoc in front of each. That part is assumed, you're just adding extras.Diplex
Still doesn't work, I've just tested in 2 computers 1 with Ubuntu and the other with Win7 both give the same problems and even if i create a new project it gives almost the same errors, must be something with android studio I guess...Cockswain
-bootclasspath /path/to/sdk/platforms/android-##/android.jar this line for some reason makes the warning go away but still the errors are alive and therefor i can't yet create the javadocCockswain
Try setting that classpath to a specific android.jar path.Diplex
now the error has something to do with this:#3049933 and this unserializableone.blogspot.com.es/2009/08/… but i have no idea how to do that, still trying to figure it out...Cockswain
@Cockswain Did you figure it out, I am having the same problem and didn't found any workaround or solution. The above solutions are not working for me.Superelevation
Pls see #78119662Superelevation
W
0

If you have a static final string variable containing the escaped unicode, you can try referencing the value of the string in the doc. Android Studio was able to resolve the unicode in the sidebar documentation for me. I don't know if this will work if you're trying to generate the doc from the command line though.

private static final String UNICODE_VALUE = "\u251c";//or whatever string

/**
 * {@value #UNICODE_VALUE}
 */
//whatever you want to document
Wriest answered 27/1, 2015 at 22:17 Comment(0)
J
0

I know this may be late, but it's worth the effort. you may add this to the gradle.build file

tasks.withType(Javadoc) {
    options.addStringOption('Xdoclint:none', '-quiet')
    options.addStringOption('encoding', 'UTF-8')
    options.addStringOption('charSet', 'UTF-8')
}
Juniorjuniority answered 17/1, 2017 at 16:52 Comment(0)
S
0

I was able to fix by combining answers from stack overflow, I answered my own question posted here Unable to generate Android Javadoc documentation in Latest Android Studio Giraffe,

Do check if anyone is still looking for an answer

Superelevation answered 3/5 at 13:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.