How to use different versions of the same gradle dependency in different Android Studio modules?

In my Android Studio project, I have two applications and a module library. Therefore, I also have two build.gradle files.

build.gradle (application):

dependencies {
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    ...
}

build.gradle (library):

    dependencies {
    compile 'com.squareup.okhttp:okhttp:2.3.0'
    ...
}

When I call some retooling methods in my library module, it uses okhttp 2.4.0 instead of 2.3.0. Why is this and how can I change this?

+4
source share
1 answer

Retrofitting most likely has a transitive dependency on okhttpand uses 2.4.0.

You may try

compile ('com.squareup.retrofit:retrofit:2.0.0-beta1'){
    exclude module: 'okhttp'
}
compile 'com.squareup.okhttp:okhttp:2.3.0'}

, okhttp, . , Retrofit / OkHttp , .

-1

Source: https://habr.com/ru/post/1607789/


All Articles