Search code examples
android-studiojavadocnullable

Error with Nullable annotation when generating Javadoc using doclava


I am trying to generate a Javadoc for an Android Library using Doclava in Android Studio. The source code uses "Nullable" tag at some point and this causes a crash while generating the javadoc:

In doclet class com.google.doclava.Doclava, method start has thrown an exception java.lang.reflect.InvocationTargetException com.sun.tools.javac.code.Symbol$CompletionFailure: class file for javax.annotation.Nullable not found

Can I somehow overcome this?


Solution

  • I had to include in Javadoc's classpath, the findbugs:jsr305 library.

    So, in my Gradle configuration, I added:

    dependencies {
    
        // For Doclava JavaDoc
        jaxDoclet("com.google.doclava:doclava:1.0.6")
        classpaths files('build/intermediates/classes/release')
        classpaths 'com.google.code.findbugs:jsr305:3.0.1'
    }
    
    task javadoc(type: Javadoc) {
         //.... the rest of the configuration
         options {
             classpath += configurations.classpaths.files.asType(List)
             //.... the rest of the configuration
          } 
    }