首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法解析组织。项目:TestApp所需的hamcrest:hamcrest-core:{strictly 1.3}

无法解析组织。项目:TestApp所需的hamcrest:hamcrest-core:{strictly 1.3}
EN

Stack Overflow用户
提问于 2021-10-28 14:55:22
回答 1查看 136关注 0票数 0

启动connectedDebugAndroidTest gradle任务时出现错误。我对项目执行了同步,它正常完成,但当我启动connectedDebugAndroidTest gradle任务时,该过程失败。

代码语言:javascript
复制
>  Could not resolve all task dependencies for configuration ':TestApp:debugAndroidTestRuntimeClasspath'
    > Could not resolve org.hamcrest:hamcrest-core:{strictly 1.3}
    Required by:
        project :TestApp
        Cannot find a version of 'org.hamcrest:hamcrest-core' that satisfies the version constraints
            Dependency path 'TestApplication:TestApp:unspecified' --> 'androidx.test.ext:junit:1.1.3' --> 'junit:junit:4.12' --> 'org.hamcrest:hamcrest-core:1.3'
            Constraint path 'TestApplication:TestApp:unspecified' --> 'org.hamcrest:hamcrest-core:{strictly 1.3}' because of the following reason: debugRuntimeClasspath uses version 1.3
            Dependency path 'TestApplication:TestApp:unspecified' --> 'androidx.test.espresso:espresso-contrib:3.4.0' --> 'com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework:3.1' --> 'org.hamcrest:hamcrest-core:2.2'
            Dependency path 'TestApplication:TestApp:unspecified' --> 'androidx.test.espresso:espresso-core:3.4.0' --> 'org.hamcrest:hamcrest-library:2.2' --> 'org.hamcrest:hamcrest-core:2.2'

我的测试依赖项是:

代码语言:javascript
复制
testImplementation "junit:junit:4.13.2"
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation "androidx.test:core:1.4.0"
androidTestImplementation "androidx.test:runner:1.4.0"
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
androidTestImplementation "androidx.test.espresso:espresso-contrib:3.4.0"
androidTestImplementation "androidx.test.espresso:espresso-intents:3.4.0"

Android gradle插件的版本为3.4.3,gradle的版本为5.6

附注:因为我花了2天来解决问题,所以添加了“下一代”的问题

EN

回答 1

Stack Overflow用户

发布于 2021-10-28 14:59:29

问题是不同的库需要不同版本的hamcrest。为了解决这个问题,我在我的:TestApp build.gradle文件中编写了以下代码:

代码语言:javascript
复制
configurations.all {
    resolutionStrategy {
        force "org.hamcrest:hamcrest-core:2.2"
    }
}

该代码被强制仅使用hamcrest库版本2.2

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69756393

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档