Build.gradle for upgrading and latest okhttp

In our application, we use a modification for networks with the following dependencies:

compile 'com.squareup.retrofit2:retrofit:2.3.0' compile 'com.squareup.retrofit2:converter-gson:2.3.0' 

Recently, we started getting this crash , which was allowed. How can I fix this in our application? I understand that the upgrade is built on top of the okHttp library. Does this mean that we will have to wait for the new version of the modification, which includes the new version of okHttp, or can I manually include the new version of okHttp in a separate dependency and as a result:

  compile 'com.squareup.retrofit2:retrofit:2.3.0' compile 'com.squareup.retrofit2:converter-gson:2.3.0' compile 'com.squareup.okhttp3:okhttp:3.8.1' 

Proguard Configuration (Modified Part Only)

 -dontnote retrofit2.Platform -dontwarn retrofit2.Platform$Java8 -dontwarn okhttp3.** -dontwarn retrofit2.** -dontwarn com.squareup.picasso.** -keep class retrofit2.** { *; } -keepattributes Signature -keepattributes Exceptions -keepclasseswithmembers class * { @retrofit2.http.* <methods>; } -keepclasseswithmembers interface * { @retrofit2.* <methods>; } -dontwarn okio.** 
+5
source share
3 answers

Yes, you can force the new okhttp version to add compile 'com.squareup.okhttp3:okhttp:3.8.1'

If you run gradlew app:dependencies , you will see the following:

 releaseCompileClasspath - Resolved configuration for compilation for variant: release +--- com.squareup.retrofit2:retrofit:2.3.0 | \--- com.squareup.okhttp3:okhttp:3.8.0 -> 3.8.1 | \--- com.squareup.okio:okio:1.13.0 

This means that Retrofit declares an okhttp:3.8.0 dependency, but Gradle will replace it with okhttp:3.8.1

PS: This applies to situations where you do not define a custom dependency resolution strategy.

0
source

Add this two and try

 compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0' compile 'com.squareup.okhttp:okhttp:2.0.0' 
0
source
 compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0' compile 'com.google.code.gson:gson:2.7' compile 'com.squareup:otto:1.3.8' compile 'com.squareup.okhttp3:logging-interceptor:3.4.1' 
0
source

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


All Articles