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.t
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')
}
Adding the following line on "other command line arguments"
fixed the errors:
-bootclasspath /path/to/sdk/platforms/android-##/android.jar
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
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"
-encoding utf-8 -bootclasspath /path/to/sdk/platforms/android-##/android.jar
followed by clicking OKyou'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.
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
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