升级依赖项后无法解析ActivityTestRule.无法导入ActivityTestRule [英] Cannot resolve ActivityTestRule after upgrading dependencies. Unable to import ActivityTestRule

查看:135
本文介绍了升级依赖项后无法解析ActivityTestRule.无法导入ActivityTestRule的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了可以正常运行的工具测试,但是现在将依赖项升级到

I have written instrumentation tests which was working fine, but now getting error cannot resolve ActivityTestRule error after upgrading dependencies to

androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

我正在使用android支持版本27.1.1

I am using android support version 27.1.1

与依赖项配合正常

androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

推荐答案

在测试支持库的最新更新(2018-04-24)中,显然已从espresso-core中删除了规则"依赖项.我不确定为什么要这么做,但是此版本笔记关于更改的说法:

In the most recent update of the Testing Support Library (2018-04-24), the "rules" dependency was apparently removed from the espresso-core. I'm not sure why this was done, but the release notes say this about the change:

修复了浓缩咖啡核心POM文件,不提取规则"依赖项,而是将浓缩咖啡意向性POM提取出来.对于开发人员来说,这应该是一个NoOp更改,因为没有espresso-core不能使用espresso-intents.

Fixed espresso-core POM file to not pull in "rules" dependency, instead have espresso-intents POM pull it. This should be a NoOp change for developers since espresso-intents cannot be used without espresso-core.

您可以通过添加以下依赖性来解决此问题.到app/build.gradle:

You can fix this problem by adding the following dependency to app/build.gradle:

androidTestImplementation 'com.android.support.test:rules:1.0.2'

这篇关于升级依赖项后无法解析ActivityTestRule.无法导入ActivityTestRule的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆