Android Studio Conflict with dependency ‘com.android.support:support-annotations’报错

2021-09-03 16:07:16 浏览数 (1)

Android Studio Conflict with dependency 'com.android.support:support-annotations'报错

强烈推介IDEA2020.2破解激活,IntelliJ IDEA 注册码,2020.2 IDEA 激活码

在Android Studio 创建新项目的时候,出现这个报错:

代码语言:javascript复制
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 添加

代码语言:javascript复制
android {
    ...
}

configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:27.1.1'
}

dependencies {
    ...
}

AS更新所导致的app与测试用例依赖库版本差异,加这段代码是为了强制使用新版本的测试用例依赖库。

0 人点赞