kpvsrkp
kpvsrkp

Reputation: 335

OkHttp(s)URLConnection class is not available in 4.9.0 version

I am having com.squareup.okhttp3:okhttp-urlconnection:3.13.1 jar as dependency in gradle file of my Android project and used as below to get the URLConnection.

protected URLConnection getStandardHTTPURLConnection(URL url) throws IOException {
    return new OkHttpURLConnection(url, builder.cookieJar(new JavaNetCookieJar(CookieHandler.getDefault())).build());
}

So I updated the jar to 4.9.0 and realized that OkHttpURLConnection is not available. It is leading to noClassDefinition exception in the run time. so what are the alternatives? Is it deprecated or moved under another hood?

Below are my imports.

import okhttp3.internal.huc.OkHttpURLConnection;
import okhttp3.internal.huc.OkHttpsURLConnection;

Kindly advice.

Upvotes: 1

Views: 787

Answers (2)

Jesse Wilson
Jesse Wilson

Reputation: 40593

There's a compatibility implementation you can paste in that's mentioned in the OkHttp 3.14.0 release notes.

https://square.github.io/okhttp/changelog_3x/#version-3140

Upvotes: 2

fr4gus
fr4gus

Reputation: 396

From https://square.github.io/okhttp/changelog_3x/ so I guess they got removed on 4.x

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.

Upvotes: 0

Related Questions