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 に答える