我所有的检测测试都有这些 gradle 依赖项:
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.1.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.1.0'
implementation 'androidx.test.espresso:espresso-idling-resource:3.1.0'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
debugImplementation 'androidx.fragment:fragment-testing:1.2.0-alpha01'
implementation 'androidx.fragment:fragment:1.1.0-alpha01'
androidTestImplementation 'org.mockito:mockito-android:2.24.5'
一旦我将它们更新为:
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.2.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.2.0'
implementation 'androidx.test.espresso:espresso-idling-resource:3.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
debugImplementation 'androidx.fragment:fragment-testing:1.2.0-alpha01'
implementation 'androidx.fragment:fragment:1.2.0-alpha01'
androidTestImplementation 'org.mockito:mockito-android:2.24.5'
并运行测试,我收到以下错误:
找不到满足 版本约束:
依赖路径"my_package_name:应用:未指定" --> 'androidx.test.espresso:espresso-intents:3.2.0' --> 'androidx.test:core:1.2.0'
....所以一个有很多线条的人
我该如何解决此问题?为什么会这样?
为什么会这样?
发生这种情况是因为 androidx.test:core:1.2.0
的版本冲突:
依赖项androidx.test.espresso:espresso-intents:3.2.0
使用核心库的版本 1.2.0。虽然还有另一个依赖项使用同一库的另一个版本,这让 Gradle 不高兴。如果您继续阅读这些大量行,您将看到另一个依赖项是什么,但我高度怀疑它androidx.fragment:fragment-testing:1.2.0-alpha01
依赖于核心库的 1.1.1 版本。
如何解决此问题:
鉴于您确实需要升级浓缩咖啡,并假设有问题的库正在片段测试,一个简单的解决方法是更改
debugImplementation 'androidx.fragment:fragment-testing:1.2.0-alpha01'
自
debugImplementation ("androidx.fragment:fragment-testing:1.2.0-alpha01", {exclude group: 'androidx.test', module: 'core' })