I have many Espresso instrumented tests. And they are working fine on Android 5.0.
Here is my build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
dexOptions {
jumboMode = true
}
defaultConfig {
applicationId "com.mycompany"
minSdkVersion 15
targetSdkVersion 23
versionCode 3
versionName "1.2.3"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": android.defaultConfig.applicationId]
}
}
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
}
testBuildType "dev"
variantFilter { variant ->
if (variant.buildType.name.equals('debug')) {
variant.setIgnore(true);
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
dev {
initWith debug
applicationIdSuffix ".dev"
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
abortOnError false
}
}
def AAVersion = '4.3.0'
dependencies {
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.0@aar') {
transitive = true;
}
compile('com.digits.sdk.android:digits:1.11.0@aar') {
transitive = true;
}
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.google.android.gms:play-services-gcm:11.0.1'
compile 'com.google.code.gson:gson:2.7'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.3'
compile 'com.squareup.okhttp:okhttp:2.7.3'
compile 'com.theartofdev.edmodo:android-image-cropper:2.2.5'
compile 'commons-codec:commons-codec:1.9'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'org.apache.httpcomponents:httpcore:4.4.4'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'org.jetbrains.anko:anko-sdk15:0.9.1'
compile 'us.feras.mdv:markdownview:1.1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':module1')
compile project(':module2')
testCompile 'junit:junit:4.12'
androidTestCompile 'junit:junit:4.12'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'junit', module: 'junit'
}
}
But if I try to start the Espresso tests on Android 4.3 I get error:
java.lang.NoClassDefFoundError: com/mycompany/activity/MainActivity$1
Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
at dalvik.system.DexFile.defineClass(Native Method)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:211)
at dalvik.system.DexPathList.findClass(DexPathList.java:313)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:51)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)