微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

原文地址:https://www.jb51.cc/android/316484.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐