prevent Javadoc from failing gradle build
Asked Answered
C

4

9

I’m trying to upload my Library project to jCenter. when I run gradlew install I’m getting the error:

Execution failed for task ':myLibraryProject:javadoc'

I added the code below to my library project:

task androidJavadocs(type: Javadoc) {
    failOnError false // add this line
    source = android.sourceSets.main.java.getSrcDirs()
}

but still I get

"Javadoc generation failed. Generated Javadoc options file..."

I've also tried the accepted answer from here: Generate JavaDocs with Android Gradle plugin

Can I disable the generation of Javadocs, or maybe try to continue with the build although the failure?

Chromoprotein answered 16/2, 2016 at 14:28 Comment(3)
I found the solution to disable JavaDocs task here: #34874675Chromoprotein
That solution disables the Javadoc task from running which is different to preventing the build from failing because of bad Javadoc in your code.Ditzel
It is helpful to check the files you have, mine was an erroneous import (Android Databinding Library). Fixed by adding the correct config (dataBinding { enabled = true }) in the android{...} on build.gradle (lib). Unfortunately, the problem still persists :(.Henig
P
5

I don't recommend disabling JavaDoc generation. Instead, try just running

./gradlew javadoc

This should give you detailed log output about the warnings and errors that are occurring. Fixing these errors should prevent JavaDoc from causing the failure.

Phial answered 18/8, 2017 at 4:20 Comment(2)
Tried this and JAVADOC getting generated successfully, but still getting the same error mentioned above.Shawnee
@DeepPatel, for me I had to fix the specific errors that were listed in the detailed log output.Phial
S
4

Add these lines to your module build.gradle

tasks.withType(Javadoc) {
      failOnError false
      options.addStringOption('Xdoclint:none', '-quiet')
      options.addStringOption('encoding', 'UTF-8')
      options.addStringOption('charSet', 'UTF-8')
}

Or you can add these:

android.libraryVariants.findAll { variant -> variant.name == 'Release' } each { variant ->
    task("generate${variant.name}Javadoc", type: Javadoc) {
        description "Generates Javadoc for $variant.name."
        source = variant.javaCompile.source
        ext.androidJar = "${android.plugin.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
        classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
    }

    task("bundle${variant.name}Javadoc", type: Zip) {
        description "Bundles Javadoc into zip for $variant.name."
        classifier = "javadoc"
        from tasks["generate${variant.name}Javadoc"]
    }
Shawnee answered 24/1, 2020 at 7:24 Comment(1)
Works with the field failOnErrorSilda
E
2

In our case, the problem was that we had to remove .gitignore files. They were listed in the file javadoc.options. After that, the task finished successfully.

Ehrlich answered 24/4, 2017 at 9:18 Comment(0)
A
2

Run your app without --deviceID. Just run npx react-native run-android . It works for me.

Aruwimi answered 25/5, 2022 at 6:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.