相关疑难解决方法(0)

Android Gradle DexException:多个dex文件定义Lorg/hamcrest/Description

com.android.dex.DexException:多个dex文件定义Lorg/hamcrest/Description

尝试通过Android Studio或我的应用程序上的Gradle命令行进行调试构建/测试时发生.

发布版本(没有测试)工作正常但是一旦包含测试(hamcrest作为测试库),构建就会因上述错误而失败.

我已经检查了我的模块依赖项,并且没有重复的要求,gradle -q依赖项证实了这一点.


项目settings.gradle

include ':[library module]'
include ':[main module]'
Run Code Online (Sandbox Code Playgroud)

项目build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
        classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.9.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}
Run Code Online (Sandbox Code Playgroud)

[library module] build.gradle

apply plugin: 'android-library'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
}

dependencies {
    compile 'com.google.zxing:core:3.0.+'
    compile 'com.bugsnag:bugsnag-android:2.1.1+'
}
Run Code Online (Sandbox Code Playgroud)

[主模块] build.gradle

apply …
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio android-gradle-plugin

28
推荐指数
3
解决办法
1万
查看次数