线程Okhttp Dispatcher中的异常

时间:2018-07-25 20:42:44

标签: java spring-mvc ant retrofit2 ivy

我在Java MVC项目中使用以下库。

    <dependency org="com.squareup.retrofit2" name="retrofit" rev="2.4.0" 
    conf="common->default"/>
    <dependency org="com.squareup.okhttp3" name="okhttp" rev="3.10.0"/>
    <dependency org="com.squareup.okio" name="okio" rev="1.14.0"/>
    <dependency org="com.squareup.retrofit2" name="converter-gson" rev="2.4.0"/>

拨打电话时出现以下错误。这是错误:

Exception in thread "OkHttp Dispatcher" java.lang.NoSuchMethodError: okio.BufferedSource.readUtf8LineStrict(J)Ljava/lang/String;
at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:215)
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:147)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

我不确定这里发生了什么。我尝试了不同版本的库,但没有任何进展。提前致谢。

1 个答案:

答案 0 :(得分:1)

我解决了这个问题,这是版本问题。这是我正在使用和工作的版本。

    <dependency org="com.squareup.retrofit2" name="retrofit" rev="2.3.0" conf="common->default"/>
    <dependency org="com.squareup.okhttp3" name="okhttp" rev="3.8.0"/>
    <dependency org="com.squareup.okio" name="okio" rev="1.13.0"/>
    <dependency org="com.squareup.retrofit2" name="converter-gson" rev="2.3.0"/>
    <dependency org="com.squareup.okhttp3" name="logging-interceptor" rev="3.8.0"/>
    <dependency org="com.google.code.gson" name="gson" rev="2.7"/>