当前位置: 代码迷 >> Android >> 将FindBugs更新为3.0.1后编译Android项目时出错
  详细解决方案

将FindBugs更新为3.0.1后编译Android项目时出错

热度:68   发布时间:2023-08-04 10:40:54.0

更新Findbugs插件高达3.0.1版本后,我无法在Android Studio中编译多模块项目。 我还使用"com.google.code.findbugs:annotations:3.0.1"依赖项来使用FindBugs注释(例如@SuppressFBWarnings )。

组装项目时出现以下错误:

Execution failed for task ':presentation:packageAllDevelopDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: javax/annotation/CheckForNull.class

我该如何解决?

我解决了这个问题,原因是添加了"com.google.code.findbugs:annotations:3.0.1"其他依赖项( 'com.google.code.findbugs:jsr305:3.0.1''net.jcip:jcip-annotations:1.0' )。 要修复它,我们需要排除一些传递依赖。

更换:

dependencies {
    compile "com.google.code.findbugs:annotations:3.0.1"
}

dependencies {
    compile ("com.google.code.findbugs:annotations:3.0.1") {
      exclude module: 'jsr305'
      exclude module: 'jcip-annotations'
    }
}

或者

dependencies {
    compile ("com.google.code.findbugs:annotations:3.0.1") {
        transitive = false
    }
}

正如之前建议的那样,排除模块jsr305对我有用,但由于导入了一个项目而不是一个模块,我使用了不同的语法。

我在我的磁盘上导入了作为独立项目存在的库项目,所以我有

compile project(path: ':shareLib')

要排除模块jsr305,我将代码转入

compile (project(path: ':shareLib')) {
    exclude module: 'jsr305'
}
  相关解决方案