美文网首页
android studio3.0新建项目编译报错

android studio3.0新建项目编译报错

作者: sybil052 | 来源:发表于2018-05-14 19:03 被阅读0次

更新了android studio,新建了一个项目,编译时发现报错了,错误信息:Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
如图:

WX20180514-174632@2x.png

大致意思就是说你测试版本用的库和最终用的库版本号不一致。按照以往的经验肯定是在dependencies里加上

androidTestImplementation 'com.android.support:support-annotations:26.1.0'  

然而并没有什么卵用。百度解决方法,看到了这篇Android studio更新到2.2之后出现的问题,直接采用简单粗暴的方法,添加force强制指定annotations

configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:26.1.0'
}

编译成功,完美解决,记录一下。

相关文章

网友评论

      本文标题:android studio3.0新建项目编译报错

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