更新了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.
如图:
![](https://img.haomeiwen.com/i5357992/8569f7010c9ffd52.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'
}
编译成功,完美解决,记录一下。
网友评论