Resolved versions for app (25.3.1) and test app (25.4.0) differ

在運行項目的時候,遇到以下問題

Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (25.3.1) and test app (25.4.0) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

經過多番查找,大致看来是 app中依赖库与test中依赖库版本不一致的问题,最后发现是因为 build.gradle 统一管理后,我在 Library的build.gradle中有测试包的依赖代码:

    //库依赖
    dependencies{
//......

    testImplementation librarys.testImplementation_test_junit
    androidTestImplementation librarys.androidTestImplementation_support_runner
    androidTestImplementation librarys.androidTestImplementation_support_espresso

//......
}

然后在 app-module的build.gradle中也有测试包的依赖代码:

    dependencies{
//......

    testImplementation librarys.testImplementation_test_junit
    androidTestImplementation librarys.androidTestImplementation_support_runner
    androidTestImplementation librarys.androidTestImplementation_support_espresso

//......

我第三方库的依赖是用config.build统一管理的,此时报错是因为Libary和app中都对测试包进行了依赖,重复了,需要删除app-module中的

    testImplementation librarys.testImplementation_test_junit
    androidTestImplementation librarys.androidTestImplementation_support_runner
    androidTestImplementation librarys.androidTestImplementation_support_espresso

测试包依赖,然后重新clean,rebuild即可。

打完收工。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,132评论 25 709
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,323评论 19 139
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 47,052评论 6 342
  • 本文原作者为:kale2010 .blog地址:http://www.cnblogs.com/tianzhijie...
    NoValue阅读 8,930评论 0 11
  • 不知道是什么驱使我看完了四谎,好久好久之前就打算看,但是,作为一只纯粹的颜狗,男女主都不是我喜欢的样子,所以一直...
    Hypnoticlyh阅读 4,461评论 0 0