Scott Mayers
Scott Mayers

Reputation: 447

Package path for okhttp3.OkHttpClient or com.squareup.okhttp.OkHttpClient

I'm building Google Maps API jar following GitHub directions :

./gradlew jar

But when creating context:

GeoApiContext context = new GeoApiContext().setApiKey("....") 

I'm getting a runtime exception:

java.lang.ClassNotFoundException: com.squareup.okhttp.OkHttpClient

This issue was reported here, and Google's gurus just recommended building project with gradle or maven, which I don't want to do.

Instead, I tried to just import okhttp-3.2.0.jar using various methods in their github repository

But for some reason, the jar includes 'okhttp3.OkHttpClient' not the 'com.squareup.okhttp.OkHttpClient' which I need.

What can I to make the code run? Is there a way to compile Google Maps API with all the dependencies? Is there a way to compile okhttp so that the package is com.squareup.okhttp instead of okhttp3?

Thanks.

Upvotes: 0

Views: 1703

Answers (1)

Jake Wharton
Jake Wharton

Reputation: 76085

You will want to get version 2.x of OkHttp which uses the com.squareup.okhttp.* package. In order for version 1/2 and version 3 to coexist in the same classpath the package name of classes was changed for versions 3.x.

You can download jars of version 2.x from Maven Central: http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.squareup.okhttp%22%20AND%20a%3A%22okhttp%22 ('jar' link on the right).

Upvotes: 3

Related Questions