美文网首页ADB
Conflict with dependency 'com.an

Conflict with dependency 'com.an

作者: 言吾許 | 来源:发表于2018-06-05 14:38 被阅读0次

    今天,在AS上新建一个项目,给我报了这么一个错误:

    AS报错
    嗯。。大体意思就是项目中的依赖包和测试的冲突了。。
    但是不影响运行,app照样可以跑起来,但是冲突不爽啊
    先用gradle view 查看一下依赖:
    testCompile
    releaseCompile
    可以看到在releaseCompile中的annotation版本为26.1.0
    而在testCompile中有一个依赖com.android.support.test:runner,而他又依赖了版本为27.1.1的annotations,问题的根源找到了,两个版本不统一。。。

    网上搜一下,发现
    https://stackoverflow.com/questions/33317555/conflict-with-dependency-com-android-supportsupport-annotations-resolved-ver两种解决方法:
    1、androidTestCompile 'com.android.support:support-annotations:26.1.0'
    试了一下,GG

    还是报错

    2、第二种,在module的gradle中,加入

    apply plugin: 'com.android.application'
    android {
      //省略
      configurations.all {
          resolutionStrategy.force 'com.android.support:support-annotations:26.1.0'
      }
    }
    

    搞定,编译通过~~
    resolutionStrategy.force的意思是强制用26.1.0的配置,再看一下gradle view


    强制依赖后

    看到已经把依赖强制从27.1.1->26.1.0了

    相关文章

      网友评论

        本文标题:Conflict with dependency 'com.an

        本文链接:https://www.haomeiwen.com/subject/tjipsftx.html