According to some references, e.g. Does Android use OkHttp internally? Android is using (or at least was using) okHttp internally under HttpUrlConnection. Still in some recent discussions (e.g. Why HTTP/2 is not supported by Android's HttpUrlConnection?) it is recommended to use okHttp from GitHub rather than Android http APIs. So I am confused. Does anyone have a definitive answer?
Asked
Active
Viewed 573 times
2
-
4why don't you just check the Android sources to be sure? – Vladyslav Matviienko Mar 05 '19 at 09:08
-
1If you bundle OkHttp with your app you're in charge of the version and included bugfixes. You're in charge of allowed protocols. Is HttpsUrlConnection good enough for your use case? Then use it, save a few kb off your APK. Is OkHttp part of Android? Yes. Should you rely on it? Depends on your use case. – Eugen Pechanec Mar 05 '19 at 10:18
1 Answers
6
From Android 4.4 onwards using OkHttp for its internal HttpUrlConnection
implementation
Source: https://twitter.com/JakeWharton/status/482563299511250944
Versions of OkHttp used in Android:
- Android 4.4: OkHttp 1.1.2
- Android 5.x: OkHttp 2.0.0
- Android 6.0: OkHttp 2.4.0
- Android 7.x: OkHttp 2.6.0
- Android 8.0+: OkHttp 2.7.5
You can check what version of OkHttp Kitkat uses here: https://android.googlesource.com/platform/external/okhttp/+/refs/heads/kitkat-release/pom.xml
For other Android releases replace kitkat-release
in the URL with <your-dessert>-release
.

Basi
- 3,009
- 23
- 28
-
1Important to note: although OkHttp is used inside of AOSP, you can't access OkHttp features like interceptors. If you want that you need to include OkHttp as a library. – Jesse Wilson Mar 05 '19 at 11:21