Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conflict with dependency 'com.squareup.okio: okio'

While running my code with Android Studio, it generates this error:

Warning: Conflict with dependency 'com.squareup.okio: okio'. Resolved versions for app (1.11.0) and test app (1.6.0) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

like image 473
Feriel LOUNES Avatar asked May 16 '17 18:05

Feriel LOUNES


2 Answers

Perhap you are adding this library for expresso UI testing with retrofit2

androidTestCompile 'com.jakewharton.espresso:okhttp3-idling-resource:1.0.0'

Here is what my solution look like:

 androidTestCompile 'com.jakewharton.espresso:okhttp3-idling-resource:1.0.0',{
        exclude group: 'com.squareup.okio', module: 'okio'
        exclude group: 'com.squareup.okhttp3', module: 'okhttp'
    }

It will keep gradle from downloading conflicting dependencies.

This problem happens because you added with androidTestCompile instead of normal compile. If you replace the former by the later, the error goes away. I think the reason is that gradle will selects the highest dependency's version.

like image 97
Phuong Dao Avatar answered Oct 20 '22 16:10

Phuong Dao


If you go to the mentioned website (http://g.co/androidstudio/app-test-app-conflict) you can read the different options you have to solve this problem.

If you cannot narrow the conflicting libraries run first the following command, to see which versions are conflicting:

./gradlew :app:dependencies

There are two possible solutions to this problem:

1.- Change the libraries versions, so they do not conflict anymore

2.- Use Gradle Conflict Resolution Mechanism to specify the version you want to resolve to.

like image 29
kikoso Avatar answered Oct 20 '22 16:10

kikoso