繁体   English   中英

我在我的应用程序中遇到与jar合并类有关的错误

[英]I am getting an error related to class with jar merging in my application

我收到类似的错误

“错误:任务':app:transformClassesWithJarMergingForDebug'的执行失败。> com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:org / apache / commons / io / CopyUtils.class”

这是我的build.gradle

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.example.user.emoapp"
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true

}
dexOptions {
    javaMaxHeapSize "4g"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
useLibrary 'org.apache.http.legacy'
packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}
}

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


compile 'com.android.support:design:23.4.0'

compile 'com.google.code.gson:gson:2.8.0'
compile 'com.microsoft.projectoxford:face:1.0.0'
compile 'org.apache.commons:commons-io:1.3.2'

}

请给我建议一个解决方案。 我t。

尝试将此添加到您的gradle

 configurations.all {
        resolutionStrategy.dependencySubstitution {
            substitute module('org.apache.commons:commons-io:1.3.2') with module('commons-io:commons-io:1.3.2')
        }
    }

完整的gradle应该看起来像这样

    android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.user.emoapp"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

    }
    dexOptions {
        javaMaxHeapSize "4g"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    useLibrary 'org.apache.http.legacy'
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
     configurations.all {
        resolutionStrategy.dependencySubstitution {
            substitute module('org.apache.commons:commons-io:1.3.2') with module('commons-io:commons-io:1.3.2')
        }
    }

}

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


    compile 'com.android.support:design:23.4.0'

    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.microsoft.projectoxford:face:1.0.0'
    compile 'org.apache.commons:commons-io:1.3.2'

    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM