I have some projects with several unit tests.
When I try to execute tests in Android Studio or from terminal using gradle clean connectedCheck
I got the following error: Test running failed: Instrumentation run failed due to 'java.lang.IncompatibleClassChangeError'
It is reproduced on Android 5.x devices, but on 4.x no errors happen.
But if I try to run separate tests package, suite, class or certain test in Android Studio, tests are going well.
I don't understand why. I need to execute tests from terminal
build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 18
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.xxx.yyy"
minSdkVersion 9
targetSdkVersion 18
testApplicationId "com.xxx.zzz.tests"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
android {
lintOptions {
abortOnError false
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile fileTree(dir: 'libs', include: '*.jar')
}
Do anybody have any suggestions?
It depends on which libs you are including. In my case, I had this problem when I included the espresso.contrib library.
You could try doing something like this though.https://stackoverflow.com/a/29423456/5280584
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With