Reputation: 83
In our application we use retrofit for networking with the following dependancies:
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
Of late we started getting this crash which has been resolved. How then do i fix this within our app? My understanding is that retrofit is built on top of the okHttp library. So does this mean we would have to wait for a new version of retrofit that includes the new okHttp version OR I can manually include the new version of okHttp as a seperate dependancy and end up with:
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 config is (only the retrofit part though)
-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.**
Upvotes: 7
Views: 5901
Reputation: 473
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'
Upvotes: -1
Reputation: 2730
Yes you can force new okhttp version by adding compile 'com.squareup.okhttp3:okhttp:3.8.1'
If you run gradlew app:dependencies
, you will see this:
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
It is means, that Retrofit declare dependency okhttp:3.8.0
, but Gradle replace it by okhttp:3.8.1
PS: This is applied for situation, when you does not define custom dependency resolution strategy
Upvotes: 3
Reputation: 3838
Add this two and try
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
Upvotes: 0