I have imported Retrofit in my project adding following to app.gradle:
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
Yet now when execute calls the app crashes with following error:
FATAL EXCEPTION: OkHttp Dispatcher
Process: com.my.app, PID: 31176
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:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
I need to import specific version of Retrofit (2.0.0-beta3) because of LoganSquare JSON parser otherwise I would consider using previous versions of Retrofit. How to resolve this problem?
The problem is that Retrofit requires certain versions of OkHttp library. And not only that, but if you import logging-interceptor you also need to ensure proper version. So, in my case this helped:
compile 'com.squareup.okhttp3:okhttp:3.0.0-RC1'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.0-RC1'
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
This is well documented on on GitHub issue page that's closed, and thus is not easy to find.
Those who complain about java.lang.AbstractMethodError: abstract method "void okhttp3.Callback.onFailure(okhttp3.Call, java.io.IOException)"
say that you can remove importing of okhttp3 altogether if you don't use logging-interceptor.
For those who use LoganSquare, you also need:
apt 'com.bluelinelabs:logansquare-compiler:1.3.4'
compile 'com.bluelinelabs:logansquare:1.3.4'
compile 'com.github.aurae.retrofit2:converter-logansquare:1.2.