0

After adding the Espresso test files I got the error. I tried many suggestions, nothing helped so far.

UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/test/BuildConfig; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)

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

The app build.gradle is:

apply plugin: '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()
    }
}

I tried many suggestions in this area, I hope you can help.

tm1701
  • 7,307
  • 17
  • 79
  • 168

1 Answers1

3

Based on the answer here and your config file, could you remove the following line from your gradle and give it a shot.

com.android.support.test:testing-support-lib:0.1
Community
  • 1
  • 1
g90
  • 506
  • 3
  • 18