0

I am converting my eclipse project into android studio by adding code of different files like menifest,java,res manually.When I run the project it shows error:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/IntegerRes.class  

Here is my gradle file:

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
useLibrary 'org.apache.http.legacy'

defaultConfig {

    applicationId "com.example.tms032.demo_pos_rs"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    testInstrumentationRunner 
    "android.support.test.runner.AndroidJUnitRunner"
}


buildTypes {
    release {

        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
{
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:multidex:1.0.1'
compile project(':CustomCalendarView')
compile files('libs/commons-discovery-0.2.jar')
compile files('libs/commons-lang-2.5.jar')
compile files('libs/gson-2.2.2.jar')
compile files('libs/javax.wsdl_1.6.2.v201005080631.jar')
compile files('libs/log4j-1.2.16.jar')
compile files('libs/picasso-2.0.0.jar')
compile files('libs/posindev.jar')
compile files('libs/printingSDK-7.5.0-javadoc.jar')
compile files('libs/sqljet.1.0.2.b885.jar')
compile files('libs/upg_bridge.jar')
testCompile 'junit:junit:4.12'

}

How to get read of this error? I have tried many solutions. but none of them works.

Vishal Yadav
  • 3,642
  • 3
  • 25
  • 42
Shuchi Sheth
  • 219
  • 2
  • 13
  • 1
    Possible duplicate of [app:transformClassesWithJarMergingForDebug FAILED](https://stackoverflow.com/questions/36763382/apptransformclasseswithjarmergingfordebug-failed) – Vishal Yadav Oct 24 '17 at 06:18
  • Two of your external libraries sharing the same class called "IntegerRes.class" so try to remove any one of the libs if not used. – Rakesh Polo Oct 24 '17 at 06:19
  • 2
    Possible duplicate of [Duplicate Entry for ':app:transformClassesWithJarMergingForDebug'](https://stackoverflow.com/questions/42782010/duplicate-entry-for-apptransformclasseswithjarmergingfordebug) – J.D. Oct 24 '17 at 06:20
  • Pls find and tell me which are the two libraries sharing the same class. I can provide you with other alternatives. – Rakesh Polo Oct 24 '17 at 06:21
  • I checked every file dependency library's class, none of containing this class. – Shuchi Sheth Oct 24 '17 at 06:30
  • it might be length of the project location. reduce and try – Lingeshwaran Oct 24 '17 at 07:02
  • @Lingeshwaran didn't work – Shuchi Sheth Oct 24 '17 at 07:16
  • @ShuchiSheth take a eclipse project backup, and convert eclipse to android studio directly from studio and see the difference in project structure and build gradle file with current project you converting now – Lingeshwaran Oct 24 '17 at 07:30
  • @Lingeshwaran both r same. while converting project from eclipse to android studio it shows different error. but gradle file is same. – Shuchi Sheth Oct 24 '17 at 08:24
  • @ShuchiSheth when converting from android studio what error or getting same error only ? – Lingeshwaran Oct 24 '17 at 08:25

1 Answers1

0
compile fileTree(include: ['*.jar'], dir: 'libs')

compile files('libs/commons-discovery-0.2.jar')

You are compiling jar files twice, also

There will be issue when there are same libraries with different version,

You could exclude them from jar dependency as below, but that hardly ever works.

sourceSets {
    main {
        java {
            include 'com/ourcompany/somepackage/activityadapter/**'
            include 'com/ourcompany/someotherpackage/**'
            exclude 'com/ourcompany/someotherpackage/polling/**'
        }
    }

The best option is to find the new version of repo instead of jar.

Niraj Sanghani
  • 1,493
  • 15
  • 23