Reputation: 1451
While trying to build an android studio project with gradle i recieve this error:
Execution failed for task ':app:transformResourcesWithMergeJavaResForPlainDebug'.
com.android.build.api.transform.TransformException:
com.android.builder.packaging.DuplicateFileException:
Duplicate files copied in APK org/apache/log4j/lf5/config/defaultconfig.properties
File1: ...\app\libs\tn5250j.jar
File2: ...\app\build\intermediates\exploded-aar\xxx\xxx\jars\libs\log4j-1.2.17.jar
In two included .jars
the library log4j
is used. I must include both libs to my android application. One of them is an .aar
file, the other is a .jar
.
Dependencies from my build.gradle
:
dependencies {
debugCompile 'xxx@aar'
releaseCompile 'xxx@aar'
compile files('libs/commons-net-3.5.jar')
compile files('libs/jackson-core-2.8.1.jar')
compile files('libs/jackson-databind-2.8.1.jar')
compile files('libs/jackson-annotations-2.8.1.jar')
compile files('libs/tn5250j.jar')
}
Packaging options from my build.gradle
:
packagingOptions {
exclude 'main/AndroidManifest.xml'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
}
Upvotes: 1
Views: 1421
Reputation: 28061
I have no idea what tn5250j.jar
is but it looks like it's an UBER jar which is packing log4j
inside. You could either exclude the log4j
dependency from your build (since it's packed inside tn5250j.jar
) or you tweak tn5250j.jar
to remove log4j
and use the "tweaked" jar instead. Eg:
dependencies {
...
compile files("$buildDir/tweaked/tn5250j-tweaked.jar")
}
task tweakTn5250j(type: Zip) {
from zipTree('libs/tn5250j.jar').matching {
exclude 'org/apache/log4j/**'
}
destinationDir = "$buildDir/tweaked"
archiveName = 'tn5250j-tweaked.jar'
}
classes.dependsOn tweakTn5250j
Upvotes: 1