Okhttp: Exception in thread "OkHttp Dispatcher" java.lang.NoSuchMethodError: okio.BufferedSource.getBuffer()Lokio/Buffer;

Created on 10 May 2019  ·  6Comments  ·  Source: square/okhttp

I use okhttpVersion = 3.14.1 and got the following error when I integrate with line bot library.

Exception in thread "OkHttp Dispatcher" java.lang.NoSuchMethodError: okio.BufferedSource.getBuffer()Lokio/Buffer;
    at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:252)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at com.linecorp.bot.client.HeaderInterceptor.intercept(HeaderInterceptor.java:39)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:221)
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:172)
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

The error because of can't resolve method getBuffer() from BufferedSource object. I think it should be source.buffer() not source.getBuffer()

bug

Most helpful comment

The versions of okhttp, okio, and HttpLoggingInterceptor need to be same.

All 6 comments

The versions of okhttp, okio, and HttpLoggingInterceptor need to be same.

What is the latest version do you suggest for okhttp, okio, and HttpLoggingInterceptor? Thank you @TangHuaiZhe

Try the same ok version as in the line library

I have the same problem, How do you solve it?

@TangHuaiZhe good

In addition to @TangHuaiZhe's comment:

I had to exclude okio as a transitive dependency of retrofit:

implementation("com.squareup.retrofit2:retrofit:2.6.4") {
    exclude group: "com.squareup.okio", module: "okio"
}
Was this page helpful?
0 / 5 - 0 ratings