问题描述
我试图准备并上传我的Android库到Bintray,并且该进程的一部分运行以下javadoc任务:
task javadoc(type:Javadoc){
source = android.sourceSets.main.java.srcDirs $ b $ classpath + = project.files(android.getBootClasspath()。join(File.pathSeparator))
这个任务是一个更大的gradle脚本的一部分:
https://raw.githubusercontent.com/attwellBrian/JCenter/master/bintrayv1.gradle
当 javadoc
任务运行时,会发生以下问题:
- 项目中的每个@NonNull和@Nullable注释报告错误error:can not find symbol。
- 每个Javadoc引用为Android类编写,如{@link Toolbar},报告error:reference not found错误。
如何在生成Javadocs时纠正这些引用问题?
编辑
它看起来像不是所有正在创建问题的Android类链接,它可能只是来自Android支持库(也是注释来自的地方)的类。在gradle依赖关系中链接源文件需要做些特别的事情吗?
解决方案您还应该将所有依赖关系添加到javadoc.classpath。试试这个:
任务javadoc(类型:Javadoc){
source = android.sourceSets.main.java.srcDirs
classpath + = project.files(android.getBootClasspath()。join(File.pathSeparator))
}
afterEvaluate {
javadoc.classpath + = files( android.libraryVariants.collect {variant - >
variant.javaCompile.classpath.files
})
}
I'm trying to prepare and upload my Android library to Bintray and part of that process runs the following javadoc task:
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
This task is part of a larger gradle script here:https://raw.githubusercontent.com/attwellBrian/JCenter/master/bintrayv1.gradle
When the javadoc
task runs, the following problems occur:
- Every @NonNull and @Nullable annotation in the project reports an error of "error: cannot find symbol"
- Every Javadoc reference I've written for an Android class, like {@link Toolbar}, reports an error of "error: reference not found"
How can I correct these reference issues when generating Javadocs?
EDITIt looks like its not all Android class links that are creating an issue, it may just be classes that come from the Android support library (which is also where the annotations come from). Does something special need to be done to link to source files in gradle dependencies?
解决方案 You should also add all your dependency to the javadoc.classpath. Try this:
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
afterEvaluate {
javadoc.classpath += files(android.libraryVariants.collect { variant ->
variant.javaCompile.classpath.files
})
}
这篇关于Android Studio Javadoc:找不到符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!