Does Android use OkHttp internally?

user3837683 picture user3837683 · Sep 23, 2014 · Viewed 10.4k times · Source

This is a stack trace I get when running an Android app I recently inherited. We're not using OkHttp as an explicitly dependency, and the com.android.okhttp in the trace makes me think the AOSP is using OkHttp now internally?

java.lang.Throwable: Explicit termination method 'close' not called
E      at dalvik.system.CloseGuard.open(CloseGuard.java:184)
E      at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:278)
E      at com.android.okhttp.Connection.upgradeToTls(Connection.java:146)
E      at com.android.okhttp.Connection.connect(Connection.java:107)
E      at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
E      at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
E      at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
E      at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
E      at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
E      at com.android.okhttp.internal.http.HttpURLConnectionImpl.getHeaderField(HttpURLConnectionImpl.java:143)
E      at java.net.URLConnection.getHeaderFieldInt(URLConnection.java:544)
E      at java.net.URLConnection.getContentLength(URLConnection.java:316)
E      at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getContentLength(HttpsURLConnectionImpl.java:182)

Answer

CommonsWare picture CommonsWare · Sep 23, 2014

Yes, Android as of Android 4.4 is using OkHttp for its internal HttpUrlConnection implementation.