okhttp: NoSuchMethodError: No virtual method log(Ljava/lang/String;)V in class Lokhttp3/internal/Platform;

it’s fine if I delete

HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); logging.setLevel(HttpLoggingInterceptor.Level.BASIC); builder.interceptors().add(logging);

but if i use okhttp3 logging-interceptor, throw this exception:

java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread. at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:62) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269) 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:833) Caused by: 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/com.ouyangzn.topgithub-2/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.execute(RealCall.java:57) at retrofit2.OkHttpCall.execute(OkHttpCall.java:174) at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$RequestArbiter.request(RxJavaCallAdapterFactory.java:171) at rx.internal.operators.OperatorSubscribeOn$1$1$1$1.call(OperatorSubscribeOn.java:85) at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:222) at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)  at java.util.concurrent.FutureTask.run(FutureTask.java:237)  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:154)  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)  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:833) 

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 4
  • Comments: 18 (6 by maintainers)

Most upvoted comments

You need to use the same version for all of your OK dependencies. If you don’t, things won’t work!

Do not downgrade Retrofit. Upgrade OkHttp.

On Wed, Sep 7, 2016, 1:52 AM ouyangzn notifications@github.com wrote:

I used the same version: compile “com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}” compile “com.squareup.okhttp3:logging-interceptor:${OKHTTP_VERSION}” OKHTTP_VERSION = 3.2.0

Now i kown, the problem is caused by retrofit, i used : compile “com.squareup.retrofit2:retrofit:${RETROFIT_VERSION}” RETROFIT_VERSION = 2.1.0

retrofit 2.1.0 used okhttp3.3.0, so …

I convert retrofit version to 2.0.2, it’s ok.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/square/okhttp/issues/2839#issuecomment-245182274, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEET1RrHgJuRQa9Lk_Fy5tuLHPXdYyks5qnlE1gaJpZM4J1luG .

I used the same version: compile “com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}” compile “com.squareup.okhttp3:logging-interceptor:${OKHTTP_VERSION}” OKHTTP_VERSION = 3.2.0

Now i kown, the problem is caused by retrofit, i used : compile “com.squareup.retrofit2:retrofit:${RETROFIT_VERSION}” RETROFIT_VERSION = 2.1.0

retrofit 2.1.0 used okhttp3.3.0, so …
I convert retrofit version to 2.0.2, it’s ok.