重复的jar条目-Android

时间:2019-11-02 16:20:46

标签: android gradle dependencies

我将第3方.aar文件添加到了我的应用中。它运行平稳,没有任何问题。但是当创建APK文件时,出现重复输入错误

* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForQaRelease'.
> java.io.IOException: Can't write [/Volumes/***/**/PROJECT/app/build/intermediates/transforms/proguard/qa/release/0.jar] (Can't read [/Users/ayeshdon/.gradle/caches/transforms-2/files-2.1/934a6f302e2712d6028d37a9dc4ccd20/jars/libs/commons-lang3-3.3.2.jar(;;;;;;;**.class)] (Duplicate jar entry [org/apache/commons/lang3/AnnotationUtils$1.class]))

我的Gradle文件是这样的:

implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
implementation (project(":LIBRARYNAME"))

这是怎么了?

1 个答案:

答案 0 :(得分:1)

无论“第三方.aar文件”是什么,它都会抱怨一些Duplicate jar entry [org/apache/commons/lang3/AnnotationUtils$1.class];因此是:

implementation (project(":LIBRARYNAME")) {
    exclude group: "org.apache.commons", module: "commons-lang3"
}

或者:

implementation fileTree(dir: "libs", include: ["*.aar", "*.jar"]) {
    exclude group: "org.apache.commons", module: "commons-lang3"
}