Conflict with dependency 'com.android.support:support-annotations' in project ':app'.

grade sync now 遇到的问题

Error:FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ‘:app:preXiaomiDebugAndroidTestBuild’.
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.

分析:
可能是名为app.gradle里面dependencies - androidTestImplementation这个依赖冲突了,app里的版本是26.1.0,但是Test app的版本里是27.1.1。

解决方法:
新增

configurations.all {
resolutionStrategy.force ‘com.android.support:support-annotations:26.1.0’
}

修改

androidTestImplementation ‘com.android.support.test:runner:1.0.2’
androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2’
⬆️修改为⬇️
androidTestImplementation ‘com.android.support.test:runner:1.0.1’
androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.1’

有其他解决方式欢迎共享~
本文参考:https://blog.csdn.net/wangzici/article/details/80140357

猜你喜欢

转载自blog.csdn.net/qq_28026283/article/details/80696075