android - 错误 JSON.simple : java. util.zip.ZipExcep

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

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. java.util.zip.ZipException: duplicate entry: 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'){ 排除组:'org.hamcrest',模块:'hamcrest-core' }

谢谢凯恩·奥莱利!

最佳答案

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

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

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

关于android - 错误 JSON.simple : java. util.zip.ZipException : duplicate entry: org/hamcrest/BaseDescription. 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32543197/

相关文章:

android - 使用 Eclipse 从命令行构建 Android 项目

ant - 什么是好的 Ant 目标命名约定?

jenkins - 远程触发构建后检查 Jenkins 作业状态

android - 使用ant构建Android项目时如何在build.properties中指定多

build - 更改 TFS 2010 中构建通知的轮询间隔

build - 寻找 .NET BuildServer SaaS

java - ANT 等待文件创建

build - 如何在 intellij idea 中构建一个 java swing 应用程序

javascript - 为什么我的 webpack bundle.js 和 vendor.bund

ios - Xcode 4.5 中的代码签名是如何完成的