Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup OkHttp v5 with Maven?

Tags:

java

maven

okhttp

OkHttp recently received a v5 update, meaning there are breaking changes. I've noticed these breaking changes, as my project no longer recognizes OkHttp or any of its classes.

Unfortunately is the changelog and README of OkHttp only really displaying info regarding a Gradle-based setup, which I don't use. I use Maven instead and currently have the dependency defined like this:

<dependencies>
  <dependency>
    <groupId>com.squareup.okhttp3</groupId>
    <artifactId>okhttp</artifactId>
    <version>5.0.0</version>
  </dependency>
</dependencies>

Am I missing something like an additional dependency or include/exclude specifications?

like image 312
Andre_601 Avatar asked Oct 14 '25 03:10

Andre_601


1 Answers

After finding an issue on their GitHub with the same problem I was able to solve the problem by depending on the `okhttp-jvm` dependency instead, as Maven doesn't seem to have the same "awareness" for module metadata as Gradle does.

So, if you're using Maven and get the same issue, try changing the okhttp artifact ID to okhttp-jvm.

like image 165
Andre_601 Avatar answered Oct 17 '25 02:10

Andre_601



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!