Android Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependen...

刚创建项目就报错,怀疑自己做了什么孽。。。
以下是我的gradle

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
// 其中依赖的是27.1.1的appcompat包
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

错误提示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.
错误提示中的test app说的就是测试工具junit,其依赖的appcompat包版本是27.1.1
所以想要解决错误,要么把appcompat版本改成27.1.1,要么不用junit,把最后三个依赖都注释了。

你可能感兴趣的:(Android Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependen...)