> 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/toos/test-apk- dependengy-conflicts.html for details.
Android Studio 新建项目报错:
>与依赖项com.android.support:support-annotations“in project”:app冲突。应用程序(26.1.0)和测试应用程序(27.1.1)的解析版本不同。见详细信息请访问https://d.android.com/r/toos/test-apk-dependengy-conflicts.html。
解决:
打开build.gradle(Module:app)文件

加入以下内容
apply plugin: 'com.android.application'
android {
//省略
//加入以下内容
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:26.1.0'
}
}
重启


本文解决了一个常见的Android Studio错误:由于应用程序和测试应用程序的com.android.support:support-annotations版本不一致导致的依赖冲突。通过在build.gradle(Module:app)文件中加入特定的配置,强制指定依赖版本,成功解决了该问题。
1374

被折叠的 条评论
为什么被折叠?



