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一看,果然:
Error:Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved_第1张图片
解决方法:
在build.gradle文件中添加如下代码,强制使二者统一:

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

即:
Error:Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved_第2张图片

好了~

你可能感兴趣的:(bug收纳盒)