android – AppCompat库23.2.1不使用espresso v2.2.2

我有一个 android项目,我使用espresso来定义测试.这一切都运行良好,但在升级到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'
    }

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...