Peter Warrington
Peter Warrington

Reputation: 694

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

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!

Upvotes: 10

Views: 6018

Answers (1)

Kane O'Riley
Kane O'Riley

Reputation: 2528

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.

Upvotes: 22

Related Questions