Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 854
Peter Warrington Avatar asked Sep 12 '15 20:09

Peter Warrington


1 Answers

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.

like image 195
Kane O'Riley Avatar answered Nov 04 '22 21:11

Kane O'Riley