AbstractMethodError using OkHttp3+Retrofit2

okhttp

I was trying out retrofit 2 and OkHttp 3, but I’ve encountered the following error message; it took sometime for me to figure the cause out so I decided to leave a note here.

The error message looks something like this:

01-18 13:23:09.248 29318-29733/your.app E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
  Process: your.app, PID: 29318
  java.lang.AbstractMethodError: abstract method "void okhttp3.Callback.onResponse(okhttp3.Call, okhttp3.Response)"
  at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133)
  at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:33)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
  at java.lang.Thread.run(Thread.java:818)

Solution

As Jake has indicated on the issue below,

Retrofit 2b3 doesn’t work with OkHttp 3 final. You’ll need to use Retrofit 2.0.0-SNAPSHOT until the next Retrofit release.

https://github.com/square/okhttp/issues/2245

I’ve fixed the dependency and everything worked well. phew.