我正在将null和容易出错的错误纳入我的应用程序,并将以下内容添加到我的顶级build.gradle
buildscript {
repositories {
google()
maven { url 'https://plugins.gradle.org/m2/' }
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.16"
}
}
subprojects {
apply from: rootProject.file("gradle/nullaway.gradle")
}
...
然后在我拥有的nullaway.gradle
文件中
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
apply plugin: 'net.ltgt.errorprone'
if (this.name == 'javalib1' || this.name == 'javalib2') {
apply plugin: 'java-library'
dependencies {
annotationProcessor deps.thirdparty.nullaway
errorprone deps.thirdparty.error_prone
}
} else {
if (this.name == 'app') {
apply plugin: 'com.android.application'
} else {
apply plugin: 'com.android.library'
}
dependencies {
annotationProcessor deps.thirdparty.nullaway
errorprone deps.thirdparty.error_prone
}
}
tasks.withType(JavaCompile) {
if (!name.toLowerCase().contains("test")) {
options.compilerArgs += [
"-Xep:NullAway:WARN",
"-XepOpt:NullAway:AnnotatedPackages=com.mypackage",
"-Xep:RestrictTo:WARN",
"-XepExcludedPaths:.*/build/generated/.*"]
}
}
通过此设置,每当我尝试构建应用时,都会出现异常
Caused by: java.lang.IllegalAccessError: tried to access class com.google.common.graph.BaseGraph from class com.google.common.graph.Traverser
at com.google.common.graph.Traverser.forTree(Traverser.java:134)
at dagger.internal.codegen.ValidationReport.<clinit>(ValidationReport.java:63)
at dagger.internal.codegen.InjectValidator.validateMembersInjectionType(InjectValidator.java:257)
at dagger.internal.codegen.InjectBindingRegistryImpl.tryRegisterMembersInjectedType(InjectBindingRegistryImpl.java:269)
at dagger.internal.codegen.InjectBindingRegistryImpl.tryRegisterMembersInjectedType(InjectBindingRegistryImpl.java:253)
at dagger.internal.codegen.InjectProcessingStep$1.visitVariableAsField(InjectProcessingStep.java:67)
at dagger.internal.codegen.InjectProcessingStep$1.visitVariableAsField(InjectProcessingStep.java:57)
at com.sun.tools.javac.code.Symbol$VarSymbol.accept(Symbol.java:1550)
at dagger.internal.codegen.InjectProcessingStep.process(InjectProcessingStep.java:56)
at dagger.shaded.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:330)
at dagger.shaded.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:181)
我检查了笔记,并且使用的是匕首2.16版,如您所见,我拥有build/generated
文件的排除项。我想念什么?