FalconBot
FalconBot

Reputation: 429

Espresso Error:Conflict with dependency 'com.android.support:support-v4'. Resolved versions for app (24.2.0) and test app (23.1.1) differ

I have upgraded to the latest API level 24 which is the latest API Level (at time of writhing) anyhow it caused this error message.

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

So How can I fix this?
Also this page the 2nd answer down gives a solution to the problem but if you want to include com.android.support.test.espresso:espresso-contrib:2.2.2 in your then this will lead to 4 more similar error messages.
So How can I get rid of these 4 extra error messages?

Upvotes: 0

Views: 1304

Answers (3)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363429

You can force the support library in your test using:

androidTestCompile 'com.android.support:support-v4:24.2.0'

Upvotes: 1

FalconBot
FalconBot

Reputation: 429

I found a solution (workaround) If you click on the picture below you will note look at the picture below you will note that the error message

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

will be fixed with the line
configurations.all {resolutionStrategy.force "com.android.support:support-v4:23.1.0"}
Which is located in the dependencies area of the gradle file
Likewise the error message

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

can be fixed with the line
configurations.all {resolutionStrategy.force "com.android.support:appcompat-v7:23.1.0"} And so on and so fourth until all the errors are solved p.s Don't forget to go here for the main solution (2nd and 3rd answer down

My Solution

Upvotes: 2

piotrek1543
piotrek1543

Reputation: 19351

Here are my Espresso build.gradle dependencies:

    androidTestCompile "com.android.support:support-annotations:$SUPPORT_VERSION"
    androidTestCompile "com.android.support.test.espresso:espresso-core:$ESPRESSO_VERSION"
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile "com.android.support.test.espresso:espresso-intents:$ESPRESSO_VERSION"
    /**
     * AccessibilityChecks
     * CountingIdlingResource
     * DrawerActions
     * DrawerMatchers
     * PickerActions (Time and Date picker)
     * RecyclerViewActions
     */
    androidTestCompile("com.android.support.test.espresso:espresso-contrib:$ESPRESSO_VERSION") {
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'support-v7'
        exclude group: 'com.android.support', module: 'design'
        exclude module: 'support-annotations'
        exclude module: 'recyclerview-v7'
    }

where:

ESPRESSO_VERSION = '2.2.2'

Check my project's build.gradle file if you still stuck: https://github.com/piotrek1543/LocalWeather/blob/master/app/build.gradle

Hope it will help

Upvotes: 2

Related Questions