0

I am trying to integrate custom framework.jar in my code and setting the priority of this new framework.jar file over android provided jar file, but while compiling the code I am getting below error :

Execution failed for task ':nuswypedev:transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:org/apache/http/conn/ConnectTimeoutException.class

How to solve this issue?

1 Answers1

0

This happens because your program jars or library jars contain multiple definitions of the listed classes.

You can check the dependencies by

./gradlew app:dependencies | grep "org.apache.httpcomponents:httpcore"

After you found the duplication, you can use reference below "exclude group" syntax to exclude one of them

Example:

dependencies {
    implementation('log4j:log4j:1.2.15') {
        exclude group: 'javax.jms', module: 'jms'
        exclude group: 'com.sun.jdmk', module: 'jmxtools'
        exclude group: 'com.sun.jmx', module: 'jmxri'
    }
}
mike
  • 373
  • 3
  • 14
  • I have following jar file "framework.jar" and I am adding it as : compile files('libs/framework.jar') How to exclude the ConnectTimeOutException class? – SHUBHAM PRAKASH Dec 20 '18 at 09:24
  • @SHUBHAMPRAKASH `compile files('libs/framework.jar') {exclude group: 'com.domain', module: 'libraryName'} ` but before that you should know which jar contains that 'ConnectTimeOutException' – mike Dec 20 '18 at 10:22