Android意外顶级例外:

时间:2015-12-23 18:26:04

标签: android android-studio android-gradle

添加Espresso测试文件后,我收到了错误消息。我尝试了很多建议,到目前为止没什么帮助。

意外的顶级例外情况: com.android.dex.DexException:多个dex文件定义了Landroid / support / test / BuildConfig;     在com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

app build.gradle是:

申请插件:' com.android.application'

android {
    signingConfigs {
        config {
           keystore stuff ... 
        }
    }
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId ...
        minSdkVersion 16
        targetSdkVersion 19
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'LICENSE.txt'
    }
}
dependencies {
    compile 'com.android.support:support-v4:22.1.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'joda-time:joda-time:2.0'
    compile files('libs/commons-io-2.4.jar')
    compile files('libs/commons-lang3-3.4.jar')
    compile files('libs/exp4j-0.4.4.jar')
    compile files('libs/GraphView-3.1.2.jar')
    compile files('libs/mapsforge-map-0.3.1-SNAPSHOT-jar-with-dependencies.jar')
    compile files('libs/osmbonuspack_v5.1.jar')
    compile files('libs/osmdroid-android-4.3.jar')
    compile files('libs/slf4j-android-1.5.8.jar')
    androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
    compile 'com.android.support:support-annotations:22.2.0'
    androidTestCompile 'com.android.support.test:runner:0.3'
    androidTestCompile 'com.android.support.test:rules:0.3'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
}
allprojects {
    repositories {
        jcenter()
    }
}

我在这方面尝试了很多建议,希望你能提供帮助。

1 个答案:

答案 0 :(得分:3)

根据答案here和你的配置文件,你可以从你的gradle中删除以下一行并给它一个镜头。

com.android.support.test:testing-support-lib:0.1