Java – okhttpclient broke after updating retrofit to retrofit 2

This error occurred after updating from retrofit to retrofit 2

The LIBS version I use in my application is:

compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0'
    compile 'com.squareup:otto:1.3.7'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'

I'm not sure if it's the okhttp version, but I tried 2.3 0 and 3.4 There are several different versions between 0, but none works

Any ideas? Thank you in advance

Solution

I have the same problem as you

First, throw it out:

compile 'com.squareup.okhttp3:okhttp:3.2.0'

The transformation has okhttp3 its dependency, so it doesn't need to And when you check here retro fit 2.1 0 depends on okhttp 3.3 0, there may be a conflict Remember that the final dependent version is the version you wrote in the gradle file If you don't write it, gradle will automatically parse it and get the correct version

There is also an updated version of logging interceptor and urlconnection:

compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'

I hope we can solve the problem

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>