4

我在运行片段测试时遇到此错误,这是一个启动 fragmentInContatiner 的简单测试:

    Cannot find a version of 'androidx.test:monitor' that satisfies the version constraints: 
   Dependency path 'Host Work.features:ui-home:unspecified' --> 'androidx.test:runner:1.2.0' --> 'androidx.test:monitor:1.2.0'
   Constraint path 'Host Work.features:ui-home:unspecified' --> 'androidx.test:monitor:{strictly 1.1.1}' because of the following reason: debugRuntimeClasspath uses version 1.1.1
   Dependency path 'Host Work.features:ui-home:unspecified' --> 'androidx.fragment:fragment-testing:1.2.0-alpha02' --> 'androidx.test:core:1.1.0' --> 'androidx.test:monitor:1.1.1'

这是造成此问题的我的 gradle 依赖项:

implementation 'androidx.fragment:fragment:1.2.0-alpha02'
debugImplementation 'androidx.fragment:fragment-testing:1.2.0-alpha02'
implementation 'androidx.test:core:1.2.0-alpha02'
implementation 'androidx.test:runner:1.2.0-alpha02'
4

2 回答 2

12

我发现了问题,不得不从片段测试依赖项中排除核心模块。正是这种冲突造成了问题。

debugImplementation ("androidx.fragment:fragment-testing:1.2.5") {
    exclude group: "androidx.test", module : "core"
}
于 2019-11-19T10:20:11.323 回答
0

只是排除module: core对我不起作用。我有同样的问题,我以这种方式成功地改变了我的浓缩咖啡依赖:

androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
debugImplementation ("androidx.fragment:fragment-testing:1.3.6") {
    exclude group:'androidx.test', module:'monitor'
}

如本官方问题所述:https ://github.com/android/android-test/issues/481

于 2021-08-18T18:48:12.283 回答