【问题标题】:Gradle install error: JavadocGradle 安装错误:Javadoc
【发布时间】:2025-12-08 11:50:01
【问题描述】:

我正在尝试将 android 库自动上传到 bintray。

我有这个应用程序的 gradle 代码:

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

ext {
    bintrayRepo = 'maven'
    bintrayName = 'CurrentCenterPositionMap'

    publishedGroupId = 'renatamelo@patriauto.org'
    libraryName = 'CurrentCenterPositionMap'
    artifact = 'current-center-position-map'

    libraryDescription = 'A library to mark the center of a map with moveing animations'

    siteUrl = 'https://github.com/leandroBorgesFerreira/CurrentCenterPositionMap'
    gitUrl = 'https://github.com/leandroBorgesFerreira/CurrentCenterPositionMap.git'

    libraryVersion = '0.8.1'

    developerId = 'leandroBorgesFerreira'
    developerName = 'Leandro Borges Ferreira'
    developerEmail = 'lehen01@gmail.com'

    licenseName = 'The Apache Software License, Version 2.0'
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
    allLicenses = ["Apache-2.0"]
}

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
repositories {
    mavenCentral()
}

// Place it at the end of the file
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'

还有这个项目的gradle:

buildscript {
    ext.kotlin_version = '1.0.4'
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

但是当我跑步时:

./gradlew install

我得到这个错误:

javadoc: error - Illegal package name: "/Users/hinovamobile/Desktop/Leandro/projetinhos/CurrentCenterPositionMap/mapfragmentwrapper/src/main/java/br/com/simplepass/mapfragmentwrapper/MapFragmentWrapper.kt"
1 error
:mapfragmentwrapper:javadoc FAILED

那么我做错了什么?我不确定如何在 Javadoc 中修复此错误...

【问题讨论】:

  • 添加--debug 标志,有助于了解问题的根源。另外,如果可能,显示MapFragmentWrapper./gradlew install --debug的内容
  • 您也可以尝试禁用 javadoc 生成 github.com/novoda/bintray-release/issues/… 并改用 KDoc
  • 嘿,谢谢。我禁用了javadoc,它起作用了。但我稍后会尝试 --debug

标签: android gradle kotlin android-library


【解决方案1】:

尝试使用 gradle-fury 的脚本来生成 javadoc。它为每个 android 变体提供不同的版本,通过 graphviz、doc-html 文件夹结构等支持 umldocs。适用于 Java 和 Android

将脚本应用到您的设置后,通过 gradlew install -Pprofile=javadoc

https://github.com/gradle-fury/gradle-fury

【讨论】:

    【解决方案2】:

    在您的主 gradle 文件中,添加以下行:

    tasks.withType(Javadoc).all {
       enabled = false
    }
    

    注意:当您在类或方法顶部按 control + 空格时,这通常仍会显示 javadocs。

    如果您想阅读更多详细信息,请查看此链接:https://github.com/novoda/bintray-release/issues/71

    【讨论】: