Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Mar 28, 2019 · 4 comments

Comments

@ghost
Copy link

ghost commented Mar 28, 2019

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
Copy link
Member

Use OkHttp 3.12.2 or newer.

@JakeWharton
Copy link
Member

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
Copy link

Zach-Dean-Attractions-io commented Feb 7, 2022

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:

  • implementation 'com.squareup.okhttp3:okhttp:4.8.0'
  • implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'
  • implementation 'com.squareup.retrofit2:retrofit:2.3.0'
  • implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

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?

  • implementation 'com.squareup.okhttp3:okhttp:4.9.2'
  • implementation 'com.squareup.okhttp3:logging-interceptor:4.9.2'
  • implementation 'com.squareup.retrofit2:retrofit:2.9.0'
  • implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

@maheritdev
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants