在AS中新建项目的时候,报错:
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.
build.gradle配置:
external Libriaries中出现两个版本的support-annotations
查询网上的资料找到了两种解决办法:
1. 在app的build.gradle里面加上这句话 ,在android{ }下面dependencies {}上面加上。
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:26.1.0'
}
2. 在dependencies {}中的implementation 'com.android.support:appcompat-v7:26.1.0'后面加上
dependencies {
implementation 'com.android.support:appcompat-v7:26.1.0'
androidTestCompile('com.android.support:support-annotations:26.1.0') {
force = true
}
...
}
两种办法都试过有效。