【问题标题】:Cannot find a version of 'androidx.test:monitor' that satisfies the version constraints找不到满足版本约束的“androidx.test:monitor”版本
【发布时间】:2019-11-19 06:59:16
【问题描述】:

我在运行片段测试时遇到此错误,这是一个启动 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'

【问题讨论】:

    标签: testing fragment android-fragmentscenario


    【解决方案1】:

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

    debugImplementation ("androidx.fragment:fragment-testing:1.2.5") {
        exclude group: "androidx.test", module : "core"
    }
    

    【讨论】:

    • 您是如何发现它是片段测试依赖项?对于刚接触 gradle 的人有什么建议可以解决这个问题?
    • @VIN 来自文档 developer.android.com/guide/fragments/test 和示例代码
    • @VIN,你可以看到 ./gradlew :app:dependencies 的依赖关系树(AndroidStudio 中可能也有这种方法)。从中,您可以看到选择了哪些版本以及选择的原因。
    【解决方案2】:

    仅排除 module: core 对我不起作用。我遇到了同样的问题,我以这种方式成功更改了我的 espresso 依赖项:

    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

    【讨论】:

      猜你喜欢
      • 2019-06-28
      • 2019-03-26
      • 1970-01-01
      • 2019-09-18
      • 2020-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-15
      相关资源
      最近更新 更多