错误JSON.simple:java.util.zip.ZipException:重复条目:org / hamcrest / BaseDescription.class

时间:2015-09-12 20:06:18

标签: android gradle build android-gradle json-simple

在添加JSON.simple并启用MultiDex后,我在android studio中遇到问题,并收到以下错误:

  

错误:任务':app:packageAllDebugClassesForMultiDex'的执行失败。    java.util.zip.ZipException:重复条目:org / hamcrest / BaseDescription.class

这是我的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'
}

谢谢。

固定:

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

谢谢Kane O'Riley!

1 个答案:

答案 0 :(得分:18)

更改json-simple导入以排除Hamcrest依赖关系,如下所示:

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

这将阻止包含多个依赖项副本。