简体   繁体   中英

Error:Conflict with dependency 'com.android.support: when update from 23.1.1 to 23.4.0

I have upgrade my build.gradle from

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'

to

compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:design:23.4.0'

However, the existence of below test libraries cause some gradle sync error

androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
    exclude group: 'com.android.support', module: 'appcompat'
    exclude group: 'com.android.support', module: 'support-v4'
    exclude module: 'support-annotations'
    exclude module: 'recyclerview-v7'
}

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2')
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.2'

The error is

Error:Conflict with dependency 'com.android.support:appcompat-v7'. Resolved versions for app (23.4.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Conflict with dependency 'com.android.support:design'. Resolved versions for app (23.4.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.4.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

How could I resolve this conflicts? Should I upgrade my test libraries as well (how to know which version to upgrade to)?

I perform various exclusion to resolve the problem. I hope there's a better answer (eg upgrade the test library?).

androidTestCompile ('com.android.support.test:runner:0.5') {
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test:rules:0.5')  {
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
    exclude group: 'com.android.support', module: 'appcompat'
    exclude group: 'com.android.support', module: 'support-v4'
    exclude group: 'com.android.support', module: 'appcompat-v7'
    exclude group: 'com.android.support', module: 'design'
    exclude module: 'support-annotations'
    exclude module: 'recyclerview-v7'
}
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test.espresso:espresso-web:2.2.2') {
    exclude group: 'com.android.support', module: 'support-annotations'
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM