AppCompat 库 23.2.1 不适用于 espresso v2.2.2

AppCompat library 23.2.1 not working with espresso v2.2.2

我有一个 android 项目,我在其中使用浓缩咖啡来定义测试。到目前为止一切正常,但在升级到 AppCompat 23.2.1(从 AppCompat 23.0.1)之后,测试的执行总是崩溃。

我的 build.gradle 依赖项:

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'

项目编译和执行正常,但是当我尝试 运行 测试时它崩溃并出现以下错误:

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

尽管错误文本我使用的是 Theme.AppCompat 的后代主题,所以我根本不理解错误消息。

有人遇到过同样的问题吗?好像是appcompat和espresso的依赖关系有问题,但是我找不到解决问题。

有什么想法吗?

谢谢!

我认为主要问题是 espresso 模块使用的支持库与我的项目中使用的支持库不同,所以当我尝试 运行 测试时,测试崩溃了。

最后我解决了它排除所有espresso模块的支持库,强制他们使用我项目的支持库。现在一切正常。希望这可以帮助任何人!

我的 gradle 看起来像这样:

    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'
    }