transformClassesWithJarMergingForDebug,com.android

2019-07-17 04:57发布

问题:

I am getting this error when trying to run application on device.However gradle sync is always successful.

Error:Execution failed for task ':EmployeeManager:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/jmdns/impl/constants/DNSConstants.class

See the Grdale file below.

    apply plugin: 'com.android.application'

repositories {
    mavenCentral()
    flatDir {
        dirs 'libs' 
    }
}
dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')

    compile(name:'jmdns-3.4.1', ext:'jar')
    compile(name:'mlite', ext:'jar')
    compile project(':EmpManager')
    compile project(':CustomerManager')
    compile project(':NGPS_COMMON_LIBS')
}

android {
    compileSdkVersion 19
    buildToolsVersion '23.0.2'
    packagingOptions{
        exclude("META.INF/LICENSE.txt")
        exclude("META.INF/README.txt")
    }

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


        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
    defaultConfig {
        multiDexEnabled true
    }

}

回答1:

I just removed packagingOptions from gradle and the issue has been resolved.