android studio 出现Error:Execution failed for task ':app:preDebugAndroidTestBuild'. 的解决办法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Dota_wy/article/details/82384418

错误代码:

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.
网上处理的几个根除的方法:

一、在app下的build.gradle文件中的dependences {}中添加如下代码:

    androidTestCompile('com.android.support:support-annotations:26.1.0') {
        force = true
    }
如果上面的没能解决的话,就用下面的这个

二、在app下的build.gradle文件中的android {}中添加如下代码:

//android 节点下添加  
 configurations.all {  
        resolutionStrategy.force 'com.android.support:support-annotations:26.1.0'  
    }  

相信到这里,你的问题应该已经解决了!

猜你喜欢

转载自blog.csdn.net/Dota_wy/article/details/82384418