【发布时间】:2017-12-11 03:49:50
【问题描述】:
我已经按照here 的说明在另一个项目中使用了 AndroidJUnitRunner。
现在我正在尝试在另一个项目中使用它,但我遇到了问题。
我补充说:
testCompile('com.android.support.test:testing-support-lib:0.1') {
exclude group: 'junit' // junit:junit-dep conflicts with junit:unit
}
发生的情况是 Android Studio 显示错误:
无法解决:com.android.support.test:testing-support-lib:0.1
并要求我安装一个新软件包。我接受并显示:
Loading SDK information...
Refresh Sources:
Fetched Add-ons List successfully
Refresh Sources
Installing Archives:
Preparing to install archives
Installing Android Support Repository, revision 15
Installed Android Support Repository, revision 15
Done. 1 package installed.
但是当我尝试同步时,我又遇到了同样的错误
无法解决:com.android.support.test:testing-support-lib:0.1
AS 要求我重新安装它。
我检查了这个包已经安装了。
【问题讨论】:
-
com.android.support.test:testing-support-lib:0.1已替换为com.android.support.test:rules:0.3。见github.com/commonsguy/cw-omnibus/tree/master/Testing/JUnit4 -
但在另一个项目上它仍然有效
-
我担心这与我没有使用 apply "plugin: 'com.android.application'" 这一事实有关,正如您从 "testCompile" 而不是 "androidTestCompile" 中看到的那样。我现在正在检查它
-
"I'm not using apply "plugin: 'com.android.application'"" -- 嗯,你需要使用
com.android.application或com.android.library,否则尝试没有意义使用 Android 的仪器测试。
标签: android unit-testing