Error JSON.simple: java.util.zip.ZipException: duplicate entry: org/hamcrest/BaseDescription.class

落花浮王杯 提交于 2019-11-30 02:57:26

问题


I am facing a problem in android studio after adding JSON.simple and enabling MultiDex and get the following error:

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. java.util.zip.ZipException: duplicate entry: org/hamcrest/BaseDescription.class

Here is my build.gradle :

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.MildlyGoodApps.EffortlessDescriptions"
    minSdkVersion 10
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true

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

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'com.android.support:multidex:1.0.0'
}

Thank you.

Fixed:

Changed compile 'com.googlecode.json-simple:json-simple:1.1.1' to compile('com.googlecode.json-simple:json-simple:1.1.1'){ exclude group: 'org.hamcrest', module: 'hamcrest-core' }.

Thank you Kane O'Riley!


回答1:


Change your json-simple import to exclude the hamcrest dependency like this:

compile('com.googlecode.json-simple:json-simple:1.1.1') {
    exclude group: 'org.hamcrest', module: 'hamcrest-core'
}

This will prevent multiple copies of the dependency being included.



来源:https://stackoverflow.com/questions/32543197/error-json-simple-java-util-zip-zipexception-duplicate-entry-org-hamcrest-bas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!