AppCompat 23.2.1 library does not work with espresso v2.2.2

I have an Android project where I use espresso to define tests. All this has worked so far, but after upgrading to AppCompat 23.2.1 (from AppCompat 23.0.1), the tests always fail.

My build.gradle dependencies:

dependencies { // Ok Config compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.2.1' compile 'com.android.support:design:23.2.1' compile 'com.android.support:support-annotations:23.2.1' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' androidTestCompile 'com.android.support.test:runner:0.5' androidTestCompile 'com.android.support:support-annotations:23.2.1' androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2' androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2' 

The project compiles and runs fine, but when I try to run the test, it crashes with this error:

 java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity 

Despite the error text, I use the Theme.AppCompat descendant theme, so I don’t understand the error message at all.

Has anyone had the same problem? There seems to be any problem with the appcompat and espresso dependencies, but I cannot find it and solve my problem.

Any ideas?

Thanks!

+7
android android-espresso
source share
1 answer

I think the main problem is that the espresso modules use a different support library than the one used in my project, so when I try to run the test, the tests fail.

Finally, I decided to exclude the support library for all espresso modules in order to force them to use the support library of my project. And now everything works fine. Hope this helps anyone!

My gradle is as follows:

  compile 'com.android.support:appcompat-v7:23.2.1' compile 'com.android.support:design:23.2.1' compile 'com.android.support:support-annotations:23.2.1' androidTestCompile ('com.android.support.test:runner:0.5') { exclude group: 'com.android.support' } androidTestCompile ('com.android.support.test:rules:0.5') { exclude group: 'com.android.support' } androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2') { exclude group: 'com.android.support' } androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2.2') { exclude group: 'com.android.support' } androidTestCompile ('com.android.support.test.espresso:espresso-intents:2.2.2') { exclude group: 'com.android.support' } 
+18
source share

All Articles