2

I was converting my android application from eclipse to Android Studio. When I built gradle there were no errors. But while running the application I got stuck with the following error:

Error:Execution failed for task ':transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/xmlpull/v1/XmlPullParserException.class

I tried to clean / rebuild project many times, but I always got the same error. I also tried Terminal command ./gradlew to clean it, but its not working.

Android Studio Version:2.1 Gradle Version: 2.1.2 jdk Version: 1.8 Android SDK Build-Tools: 24

build.gradle code:

    apply plugin: 'com.android.application'

dependencies {

    compile ('com.google.android.gms:play-services:9.0.2')
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile files('libs/appcompat_v7.jar')
    compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')
    compile files('libs/gcm.jar')
    compile files('libs/android.jar')
    compile files('libs/activation.jar')
    compile files('libs/additionnal.jar')

    compile ('com.google.android.gms:play-services-analytics:9.0.2')
    compile files('libs/libGoogleAnalyticsServices.jar')
    compile files('libs/mail.jar')
    compile "com.android.support:support-v4:24.0.0"
    compile "com.android.support:design:24.0.0"
    compile 'com.android.support:multidex:1.0.1'
}

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    useLibrary  'org.apache.http.legacy'

    defaultConfig {

        applicationId "com.expedite.apps.vedant"
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }


    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}
Lips_coder
  • 686
  • 1
  • 5
  • 17
Monark Patel
  • 159
  • 2
  • 15
  • Add this... in your project build... packagingOptions { exclude 'META-INF/NOTICE.txt' // will not include NOTICE file exclude 'META-INF/LICENSE.txt' // will not include LICENSE file } – Arjun saini Jun 24 '16 at 04:22
  • Thank You For answered on my Question. Now i was added in the build.gradle but error is not solved. Sol please give me other solution. – Monark Patel Jun 24 '16 at 04:37
  • Same error occur ?? with my answer – Arjun saini Jun 24 '16 at 04:38
  • Yes. Error:Execution failed for task ':transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/xmlpull/v1/XmlPullParserException.class – Monark Patel Jun 24 '16 at 04:44

2 Answers2

1

I solve my Error:

Following my build.gradle code:

    apply plugin: 'com.android.application'

dependencies {
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile('com.google.android.gms:play-services:9.0.2')
    compile ('com.google.android.gms:play-services-analytics:9.0.2')
    compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')
    compile "com.android.support:design:24.0.0"
    compile 'com.android.support:multidex:1.0.1'
    compile files('libs/mail.jar')
    compile files('libs/activation.jar')
    compile files('libs/gcm.jar')
}

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    useLibrary  'org.apache.http.legacy'

    defaultConfig {

        applicationId "com.expedite.apps.vedant"
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    packagingOptions {
        exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
        exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
        exclude 'META-INF/LICENSE-FIREBASE.txt'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

Add This one line in AndroidManifest.xml android:name="android.support.multidex.MultiDexApplication"

<application
 .....
 android:name="android.support.multidex.MultiDexApplication">
</application>
Monark Patel
  • 159
  • 2
  • 15
0

Add Some Code in Your Build

I am adding some Lines like Package Option and Build Types...

apply plugin: 'com.android.application'

dependencies {


compile 'com.android.support:appcompat-v7:24.0.0'
compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')

compile 'com.google.android.gms:play-services:+'
compile files('libs/libGoogleAnalyticsServices.jar')

compile "com.android.support:support-v4:24.0.0"
compile "com.android.support:design:24.0.0"
compile 'com.android.support:multidex:1.0.1'

}

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.1.2'
}
}

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary  'org.apache.http.legacy'



defaultConfig {

    applicationId "com.expedite.apps.vedant"
    minSdkVersion 9
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}


 packagingOptions {
    exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
    exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
}
buildTypes {
    release {
            minifyEnabled false
               proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    // Move the tests to tests/java, tests/res, etc...
    instrumentTest.setRoot('tests')

    // Move the build types to build-types/<type>
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
    // This moves them out of them default location under src/<type>/... which would
    // conflict with src/ being used by the main source set.
    // Adding new build types or product flavors should be accompanied
    // by a similar customization.
    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
}
}
Arjun saini
  • 4,223
  • 3
  • 23
  • 51
  • Thank You For answered on my Question. Now i was added in the build.gradle but error is not solved. Sol please give me other solution. – Monark Patel Jun 24 '16 at 04:38
  • Try to clean project and rebuild again.after placing this code – Arjun saini Jun 24 '16 at 04:43
  • And Also Try to add the compile('com.google.android.gms:play-services:8.1.0') { exclude group: 'com.android.support', module: 'support-v4' } Instead of compile ('com.google.android.gms:play-services:9.0.2') – Arjun saini Jun 24 '16 at 04:45
  • Yes I tried to clean project and rebuild but same error occur. Error: Error:Execution failed for task ':transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/xmlpull/v1/XmlPullParserException.class – Monark Patel Jun 24 '16 at 04:45
  • Otherwise you also Compile with compile 'com.google.android.gms:play-services:+' – Arjun saini Jun 24 '16 at 04:46
  • Can u remove compile files('libs/appcompat_v7.jar') this line and try – Raghavendra Jun 24 '16 at 04:49
  • @Raghavendra: I remove compile files('libs/appcompat_v7.jar') line. error is change: Error:Execution failed for task ':transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/analytics/internal/Command$1.class – Monark Patel Jun 24 '16 at 05:20
  • What use of this Dependencies remove these.. compile files('libs/mail.jar') compile files('libs/gcm.jar') compile files('libs/android.jar') compile files('libs/activation.jar') compile files('libs/additionnal.jar') Try to Update answer cLEAN AND bUILD TELL WHAT ERROR NOW. – Arjun saini Jun 24 '16 at 05:26
  • @Er.Arjunsaini i cant remove this compile files because i used in the project. I tried to remove and rebuild but import error occurs. – Monark Patel Jun 24 '16 at 05:59
  • Than Take This All But Update only compile 'com.google.android.gms:play-services:+' remove compile ('com.google.android.gms:play-services:9.0.2') compile ('com.google.android.gms:play-services-analytics:9.0.2') – Arjun saini Jun 24 '16 at 06:12