10

添加 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' }

谢谢凯恩·奥莱利!

4

1 回答 1

21

更改您的json-simple导入以排除 hamcrest 依赖项,如下所示:

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

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

于 2015-09-13T10:02:54.013 回答