I got this error after updated from retrofit to retrofit2.
FATAL EXCEPTION: OkHttp Dispatcher Process: nz.co.datacom.mars.junction, PID: 21616
java.lang.NoSuchMethodError: No virtual method log(Ljava/lang/String;)V in class Lokhttp3/internal/Platform; or its super classes (declaration of 'okhttp3.internal.Platform' appears in /data/app/nz.co.datacom.mars.junction-1/base.apk)
at okhttp3.logging.HttpLoggingInterceptor$Logger$1.log(HttpLoggingInterceptor.java:109) at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:157) at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163) at okhttp3.RealCall.access$100(RealCall.java:30)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
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)
The libs version I used in the app are:
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0'
compile 'com.squareup:otto:1.3.7'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
Not really sure if it is because of the okhttp version or not, but I tried few different version between 2.3.0 and 3.4.0 and none of them work.
Any ideas? Thanks in advance.
Had the same problem as you.
First of all, throw out:
compile 'com.squareup.okhttp3:okhttp:3.2.0'
Retrofit has okhttp3
as it's dependency so it is not needed. Moreover, when you check here Retrofit 2.1.0
depends on okhttp 3.3.0
, so there might be a conflict. Remember, that the final dependency version is the one you write in gradle
file. If you don't write it, then Gradle
automatically resolves it and fetches the right version.
There is also a newer version of Logging Interceptor and urlconnection:
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
Hope that solves the problem.
In addition, the most important thing to understand the fix is to ensure that okhttp3 dependencies have all the same version number as stated here by collaborators
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With