OkHttp 3 and HttpURLConnection
I tried to depend on
com.squareup.okhttp:okhttp-urlconnection:3.0.0
but that doesn't exist.
The names were updated as well. It is now
com.squareup.okhttp3:okhttp-urlconnection:3.0.0
NOte the okhttp3
instead of okhttp
.
For more information on the reasoning behind this, see Jake Wharton (the author)'s blog post on Java Interoperability Policy for Major Version Updates here:
https://jakewharton.com/java-interoperability-policy-for-major-version-updates/
See jCenter.
BoD
Please see my personal home page http://JRAF.org or my Google+ public profile at http://JRAF.org/+
Updated on June 07, 2022Comments
-
BoD about 2 years
I am a bit confused about how to upgrade OkHttp to v3.0.0 while keeping our code that uses
HttpURLConnection
. Our current dependencies are:compile 'com.squareup.okhttp:okhttp:2.7.0' compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.0'
The changelog states:
The Apache HTTP client and HttpURLConnection APIs are deprecated. They continue to work as they always have, but we're moving everything to the new OkHttp 3 API. The okhttp-apache and okhttp-urlconnection modules should be only be used to accelerate a transition to OkHttp's request/response API. These deprecated modules will be dropped in an upcoming OkHttp 3.x release.
Unfortunately it is not clear to me what "we're moving everything to the new OkHttp 3 API" means.
I tried to depend on
com.squareup.okhttp:okhttp-urlconnection:3.0.0
but that doesn't exist.Should I keep
com.squareup.okhttp:okhttp-urlconnection:2.7.0
and upgrade onlycom.squareup.okhttp:okhttp
to 3.0.0? Or does this sentence mean that depending only oncom.squareup.okhttp:okhttp
should work? -
BoD over 8 yearsDoh! The funny thing is I saw this, but then my brain decided to black it out ;) Thanks!
-
BoD over 8 yearsExcept now I have this weird problem:
com.android.dex.DexException: Multiple dex files define Lokhttp3/Address;
edit.. which I fixed like this, but this is weird:compile ('com.squareup.okhttp3:okhttp-urlconnection:3.0.0') { exclude group: 'com.squareup.okhttp3' }
-
Tim over 8 years@BoD new problem -> new question
-
BoD over 8 yearsI ended up opening a ticket here about this second problem: github.com/square/okhttp/issues/2243
-
atreat about 8 yearsUsing
com.squareup.okhttp3:okhttp-urlconnection:3.0.1
seems to fix the github issue.