square / retrofit

A type-safe HTTP client for Android and the JVM
https://square.github.io/retrofit/
Apache License 2.0
43.12k stars 7.3k forks source link

java.lang.NoSuchMethodError: okhttp3.HttpUrl.get(Ljava/lang/String;)Lokhttp3/HttpUrl; #3058

Closed ghost closed 5 years ago

ghost commented 5 years ago

when I set baseUrl,I got a problem : java.lang.NoSuchMethodError: okhttp3.HttpUrl.get(Ljava/lang/String;)Lokhttp3/HttpUrl;

This problem only happened when I used version 2.5 , if I uesd 2.4 ,it is OK.

I have solved this problem , the okhttp version mismatch the retrofit version, when I used both the newest version , this problem is solved

swankjesse commented 5 years ago

Use OkHttp 3.12.2 or newer.

JakeWharton commented 5 years ago

And the pom declares a dependency on that version so if it wasn't present you like have a misconfiguration on the side of your build system which we can't control.

Zach-Dean-Attractions-io commented 2 years ago

Update Solved: I had another library, which was dependant upon OkHttp:3.8.0 and so this was being used and causing the issue. When I do not use this library I can use say OkHttp:3.14.9 (same for the logging interceptor) and upgrade retrofit to version 2.6.0 or above.

Hi,

Currently my project is using:

I tried to move the retrofit & gson converter library to version 2.6.0 or 2.9.0, however I then get the error:

java.lang.NoSuchMethodError: No static method get(Ljava/lang/String;)Lokhttp3/HttpUrl; in class Lokhttp3/HttpUrl; or its super classes (declaration of 'okhttp3.HttpUrl' appears in 
        at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:506

I tried upgrading all of the libraries to their latest versions, but I still get the same error. Any ideas on where I'm going wrong?

maheritdev commented 2 years ago

I tried all of these solutions but with no benefits unfortunately.