Android studio更新到2.2之后出现的问题

升级Android Studio到2.2版本后,遇到运行错误,提示app和test app的support-annotations版本冲突。尝试访问官方链接未找到明确解决办法,经过搜索和排查,发现在build.gradle的dependencies中问题不只一处。解决方案涉及Espresso Contrib的bug,需要通过force指定annotations版本来修复。
摘要由CSDN通过智能技术生成

更新完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-
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值