引起:java.lang.NoSuchMethodError:com.squareup.okhttp.internal.Internal.getHttpUrlChecked

时间:2016-10-08 10:08:46

标签: java retrofit fullcontact okhttp

我在尝试点击FullContact API服务器时遇到此错误。我正在使用okhttp 2.7.5和okhttp-urlconnection 2.7.5并改进1.9.0。

Caused by: java.lang.NoSuchMethodError: com.squareup.okhttp.internal.Internal.getHttpUrlChecked(Ljava/lang/String;)Lcom/squareup/okhttp/HttpUrl;
        at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.newHttpEngine(HttpURLConnectionImpl.java:339)
        at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.initHttpEngine(HttpURLConnectionImpl.java:324)
        at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:392)
        at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:527)
        at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
        at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
        at com.fullcontact.api.libs.fullcontact4j.http.FCUrlClient.readResponse(FCUrlClient.java:148)
        at com.fullcontact.api.libs.fullcontact4j.http.FCUrlClient.execute(FCUrlClient.java:91)
        at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
        ... 7 more

1 个答案:

答案 0 :(得分:2)

只有当您的代码编译所使用的库/ jar版本与用于运行时执行依赖项的库不相容时,才会出现此问题。

确保两个地方都有正确的版本。

也可能是您通过显式添加库jar来编译源代码的情况。 但是在运行时,服务器正在从没有所需方法的不同版本jar加载库类。