Android Gradle javadoc注释不存在

我试图建立一个aar发布在jcenter。

assembleRelease任务工作正常,javadoc任务也可以正常工作,但javadocJar任务会输出此错误:

/Users/martinmoreno/Projects/android-dev-utils/dev-utils/src/main/java/com/tinchoapps/devutils/BitmapUtils.java:11: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;

这是(简化)毕业文件:

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'


android {
    ...
    buildTypes {
        release {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.debug
        }
    }
...
}

...

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:support-annotations:20.0.0'
    compile 'com.android.support:support-v4:22.0.0'
}

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    destinationDir = file("../javadoc/")
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar
    archives javadocJar
}

它似乎与依赖关联,因为它在导入内的类中给出了一些“类未找到”异常,但无法弄清楚出了什么问题。

有什么想法吗?

这固定了我的各种类似的错误:

将以下内容添加到build.gradle中:

configurations {
    javadocDeps
}

dependencies {
    compile 'com.android.support:support-annotations:22.2.0'
    javadocDeps 'com.android.support:support-annotations:22.2.0'
    androidTestCompile 'junit:junit:4.+'
    androidTestCompile 'com.jayway.android.robotium:robotium-solo:+'
}

在JavaDoc任务中添加以下行:

classpath += configurations.javadocDeps
http://stackoverflow.com/questions/29663918/android-gradle-javadoc-annotation-does-not-exists

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:Android Gradle javadoc注释不存在