Java – Gradle build fails with Javadoc NullPointerException

Gradle build fails with Javadoc NullPointerException… here is a solution to the problem.

Gradle build fails with Javadoc NullPointerException

I just updated one of my projects to Android L with the new build tools 21.0.2 and the new gradle 2.1.

Now, once I build the project on my system, I get the following exception:

import com.tundem.aboutlibraries.R;
                                ^
  symbol:   class R
  location: package com.tundem.aboutlibraries
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:459)

4 warnings
    at com.sun.tools.doclets.internal.toolkit.util.Util.getAllInterfaces(Util.java:497)
    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:606)
    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)
:sample:lintVitalRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':library:generateDebugJavadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds/project-9/library/build/tmp/generateDebugJavadoc/ javadoc.options'

If I build the same project in Android Studio, no problem. Right on my build server (using Ubuntu).

Is there any way to disable Javadoc generation, or how can I fix this.

The only information I found is that this happens if there is a unicode character in the project, but I didn’t add one.

I’ve also added Appcompat and support libraries.

Thank you.

Solution

The solution to this problem is to remove all HTML-formatted tags in the My Methods document.

In some comments I have html elements that close automatically, which causes some problems.

But I still haven’t found why they changed it with the latest version.

Related Problems and Solutions