关于android studio 出现Error:Execution failed for task ':app:preDebugAndroidTestBuild'. 的解决办法
Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependency
2018年05月16日 15:32:44 _Creater_ 阅读数:10491 标签: android dependency conflict error 更多 个人分类: android error前段时间打开Android studio 在build过程中总会出现以下错误
- 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->Rebuid-project
后,重新build后发现问题解决了。可是每当新建文件,或者重启AS后又会出现此类情况,虽然可以解决,但是并不彻底。于是便寻找错误根源。仔细阅读发现问题
Resolved versions for app (26.1.0) and test app (27.1.1) differ
于是便查看app下build.gradle文件,发现并没有错误compileSdkVersion 为26,可是没有发现27.1.1版本的com.android.support:support-annotations。可是上述信息明显是版本冲突,于是在external library中寻找
发现了依赖包冲突。于是根据自己的编译版本删除多余的包27.1.1(笔者compileSdkVersion 为26),rebuild后问题解决。可是重启以后问题还会复现。于是上网继续寻找方法。再尝试了很多方法后,找到了一个方法解决了该问题。解决方法如下:
在app下的build.gradle文件中的dependences {}中添加如下代码:
- androidTestCompile('com.android.support:support-annotations:26.1.0') {
- force = true
- }
添加后dependences中结构类似
- dependencies {
- androidTestCompile('com.android.support:support-annotations:26.1.0') {
- force = true
- }
- ...
- }
android gradle 报错
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.
解决方法 1
1st
于
app的
build.gradle中, 在
android{...}里添加如下代码:
configurations.all { resolutionStrategy.force 'com.android.support:support-annotations:27.1.1' }
2st
同步
build.gradle文件
解决方法 2
于
app的
build.gradle中, 在
android{...}里,更改一下属性,使其为最近版本号,如下
写于2018/05,自行去官网里寻找适合版本 ——[developer.android.com]
andorid{ ... defaultConfig { compileSdkVersion 27 defaultConfig { ... targetSdkVersion 27 ... } ... } ... }
解决方法1:
我们可以重新构建项目(rebuild project)
解决方法2:
我们将依赖中的com.android.support:appcompat-v7版本改为报错中提到的测试版本:
最后将项目同步一下就可以解决。
总结
新手主义看报错信息 '.Conflict with dependency 'com.android.support:support-annotations' 说明是依赖冲突, Resolved versions for app (26.1.0) and test app (27.1.1) differ 给出了冲突的版本,之后要么把冲突的地方降级为 (26.1.0), 要么把整个升级为版本 27
- 关于android studio 出现Error:Execution failed for task ':app:buildInfoDebugLoader'.的解决办法
- 关于android studio 出现Error:Execution failed for task ':app:buildInfoDebugLoader'.的解决办法
- 关于android studio 出现Error:Execution failed for task ':app:buildInfoDebugLoader'.的解决办法
- 关于android studio 出现Error:Execution failed for task ':app:buildInfoDebugLoader'.的解决办法
- 关于解决android studio出现Error:Execution failed for task ':app:mergeDebugResources'. 的方法
- Android Studio运行程序出现Session ‘app’: Error Launching activity 解决办法
- android studio 出现Error:Execution failed for task ':app:buildInfoDebugLoader'.的解决办法
- 关于解决android studio出现Error:Execution failed for task ':app:mergeDebugResources'. 的方法
- Android Studio运行程序出现Session ‘app’: Error Launching activity 解决办法
- Android Studio运行程序出现Session ‘app’: Error Launching activity 解决办法
- 关于Android Studio 出现Unrecognized Windows Sockets error: 10107: Socket creation failed解决办法
- Android Studio运行或Rebuild的时候报Error:Execution failed for task ':app:compileDebugNdk'.的解决办法
- Android Studio升级到2.3.1,小米MI无法安装apk,安装失败,闪退,即时运行 失败,Session 'app': Error Installing APKs,问题解决办法
- 关于Nios中对EPCS进行flash烧写出现以下错误Error: Error code: 8 for command: nios2-flash-programmer...的解决办法
- 关于Android studio出现Error:(44, 0) Gradle DSL method not found: 'apt()' 错误的解决办法
- Android studio 打开monitor 出现error提示 的解决办法 特别是使用了JDK-9
- 关于出现错误:_tkinter.TclError: couldn't open "E:\Python系列\Python程序\Python安装.gif"tkinter中不能打开GIF格式图片的解决办法
- npm安装create-react-app出现“Error: EACCES: permission denied”的解决办法
- 关于:MySQL 安装过程中出现“could not start the service mysql error:0”的解决办法。
- Android Studio运行或Rebuild的时候报Error:Execution failed for task ':app:compileDebugNdk'.的解决办法