Android studio更新到2.2之后出现的问题
来源:互联网 发布:汕头美工培训机构 编辑:程序博客网 时间:2024/05/16 01:02
更新完AS之后去写作业,发现怎么弄都是没法运行,提示的错误是Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (22.2.1) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
大致意思就是说你测试版本用的库和最终用的库版本号不一致
打开后面给的链接发现真的是什么都没说啊!百度了半天没有找到什么中文资料,只能看看国外的网站有什么相关的解决方法。
折腾了好久大概总结出来问题在哪里了。写下来帮大家解决这个问题。
首先先定位问题出现在哪里,build.gradle里面的dependencies里面
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.1' compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1' testCompile 'junit:junit:4.12' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' androidTestCompile 'com.android.support.test:runner:0.5' androidTestCompile 'com.android.support:support-annotations:23.1.1'}一眼瞅过去肯定以为只要把最后一项
com.android.support:support-annotations:23.1.1
后面修改为22.2.1就行了是吧?naive。
我这么试了发现根本就不行。查了好久才发现并不只是这一句有问题,在google之后http://stackoverflow.com/questions/28999124/resolved-versions-for-app-22-0-0-and-test-app-21-0-3-differ给出了一些解释。
Looks like it's espresso-contrib
+--- com.android.support.test:testing-support-lib:0.1 (*)\--- com.android.support.test.espresso:espresso-contrib:2.0 +--- com.android.support:recyclerview-v7:21.0.3 | +--- com.android.support:support-annotations:21.0.3 | \--- com.android.support:support-v4:21.0.3 | \--- com.android.support:support-annotations:21.0.3 +--- com.android.support:support-v4:21.0.3 (*) \--- com.android.support.test.espresso:espresso-core:2.0 (*)
参考过后就知道了,就是说下面的androidTestCompile项目中,espresso那一项当中还有包含23.1.1的引用,你要是把androidTestCompile那几条都注释了再运行就发现编译通过了。。。下面有人回答说Actually it's a bug of new update version of Espresso Contrib
好吧,有幸遇到这种存在在环境中的bug了,给出的解决方法简单粗暴,添加force强制指定annotations
configurations.all { resolutionStrategy.force 'com.android.support:support-annotations:22.1.0'}
把这一项添加到dependencies里面就可以了。再去试一试dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.1' compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1' testCompile 'junit:junit:4.12' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' androidTestCompile 'com.android.support.test:runner:0.5' androidTestCompile 'com.android.support:support-annotations:22.2.1' configurations.all { resolutionStrategy.force 'com.android.support:support-annotations:22.1.0' }}终于build successful
- Android studio更新到2.2之后出现的问题
- Android studio更新到2.2之后出现的问题
- Android studio更新到2.2之后出现的问题
- 更新Android Studio到2.3.1出现的问题
- 关于Android Studio 更新到3.0版本以后出现的一些问题以及解决方案
- Android Studio升级到2.3.3之后的打包问题
- 热更新之后出现的问题
- Android Studio 2.3 更新时出现的问题
- Android Studio 更新 Android 6.0 之后无法使用 org.apache.http 包的问题
- Android Studio 更新 Android 6.0 之后无法找到 org.apache.http 包的问题
- Android Studio 更新 Android 6.0 之后无法找到 org.apache.http 包的问题
- Android Studio 更新 Android 6.0 之后无法找到 org.apache.http 包的问题
- Android Studio 更新 Android 6.0 之后无法找到 org.apache.http 包的问题
- Android Studio 更新 Android 6.0 之后无法找到 org.apache.http 包的问题
- android studio从2.2.2更新到2.3之后第一次启动超级慢解决办法
- android studio更新到1.5后遇到的问题
- 导入Eclipse工程 到 Android Studio以及出现的问题
- Android Studio升级到3.3出现的问题-手动解决办法
- nodejs模拟get,post 进行字符统计功能
- 【GDOI 2016 Day1】第四题 疯狂动物城 题解+代码
- bzoj 1003: [ZJOI2006]物流运输 动态规划+最短路
- LK源码解析 1 crt0.s
- android基于Android Studio的持续集成CI
- Android studio更新到2.2之后出现的问题
- js制作淘宝放大镜效果
- Android 仿iOS右滑 finish 界面
- hdoj 2033人见人爱A+B 解题报告
- ES5中新增的Array方法
- 第十三周项目52-虚析构函数
- python的sort()函数详解
- 斜杠和反斜杠
- Android中混淆的使用