When I'm adding the
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
in the gradle and run an Espresso test, I get the following error:
Testing started at 5:59 PM ...
02/08 17:59:58: Launching changeText_sameAct...()
No apk changes detected since last installation, skipping installation of /Users/xxx/Documents/home/MasterDetails/app/build/outputs/apk/app-debug.apk
$ adb shell am force-stop databinding.com.masterdetails
No apk changes detected since last installation, skipping installation of /Users/xxx/Documents/home/MasterDetails/app/build/outputs/apk/app-debug-androidTest-unaligned.apk
$ adb shell am force-stop databinding.com.masterdetails.test
Running tests
$ adb shell am instrument -w -r -e debug false -e class databinding.com.masterdetails.TestPostListActivity#changeText_sameActivity databinding.com.masterdetails.test/android.support.test.runner.AndroidJUnitRunner
Client not ready yet..Waiting for process to come online
Connected to process 10355 on device samsung-sm_g920f-01157df1bc4b5336
Test running started
java.lang.IncompatibleClassChangeError: databinding.com.masterdetails.PostListActivity
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:321)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at databinding.com.masterdetails.TestPostListActivity.<init>(TestPostListActivity.java:25)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:240)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1889)
Tests ran to completion.
and the tests aren't running. I suspect is a gradle problem so here is my app gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
dataBinding {
enabled = true
}
defaultConfig {
applicationId "databinding.com.masterdetails"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
androidTestCompile 'com.android.support:support-annotations:23.1.1'
// Android JUnit Runner
androidTestCompile 'com.android.support.test:runner:0.4.1'
// JUnit4 Rules
androidTestCompile 'com.android.support.test:rules:0.4.1'
// Espresso core
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
// Espresso-contrib for DatePicker, RecyclerView, Drawer actions, Accessibility checks, CountingIdlingResource
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:2.2.1'
}
I need to add
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
so I can test with RecyclerView.
Please check my dependendecies, especially
espresso
ones.}
where
def ASVersion = '23.1.1'
Maybe you missed something. Mine already working
Hope it help
Seems that you include
RecyclerView
component twice: here -compile 'com.android.support:recyclerview-v7:23.1.1'
and hereandroidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
. Add below code in yourbuild.gradle
after dependencies section and try again: