Error:Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved

出现一个如下错误:

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.

通过“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”可知是jar包冲突,打开External Libraries一看,果然:
在这里插入图片描述
解决方法:
在build.gradle文件中添加如下代码,强制使二者统一:

androidTestImplementation('com.android.support:support-annotations:26.1.0') {
    force = true
}

即:
在这里插入图片描述

好了~

发布了85 篇原创文章 · 获赞 152 · 访问量 28万+

猜你喜欢

转载自blog.csdn.net/cjm2484836553/article/details/93545032