Okhttp: HttpLoggingInterceptor crashes when using DEFAULT Logger when using OkHttp 2.5

Created on 12 Nov 2015  Â·  4Comments  Â·  Source: square/okhttp

The DEFAULT Logger in HttpLoggingInterceptor is using Platform.get().log(String) method. That method doesn't exist in OkHttp 2.5

build.gradle

compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.okhttp:logging-interceptor:2.6.0-SNAPSHOT'

Crash

java.lang.NoSuchMethodError: com.squareup.okhttp.internal.Platform.log
at com.squareup.okhttp.logging.HttpLoggingInterceptor$Logger$1.log(HttpLoggingInterceptor.java:109)
at com.squareup.okhttp.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:152)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:221)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195)
at com.squareup.okhttp.Call.access$100(Call.java:34)
at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:162)
at com.squareup.okhttp.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:841)

Platform has a logW(String warning) method that could be used instead.
That or remove the HttpLoggingInterceptor() constructor if you want consumers to specify the Logger

Most helpful comment

That message indicates you are using a different logger version than the
main okhttp artifact. You can likely fix it by adding an explicit
dependency on OkHttp with the same version as the logger.

On Thu, Aug 25, 2016 at 10:31 AM kiranbjm [email protected] wrote:

FATAL EXCEPTION: OkHttp Dispatcher
java.lang.NoSuchMethodError: okhttp3.internal.Platform.log
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:1076)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)

I am using
_gradle_
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/square/okhttp/issues/1992#issuecomment-242408309, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAEEEYGQFal_Ydt2XXLr4Y9PQx6fFt-wks5qjacwgaJpZM4Ghabg
.

All 4 comments

You have to use 2.6.0-SNAPSHOT of okhttp for this to work, or just copy/paste the interceptor and modify its implementation to use whatever logger you want. We don't support using multiple artifacts from the library with different versions.

Thanks & confirmed that upgrading to 'com.squareup.okhttp:okhttp:2.6.0-SNAPSHOT' solves the problem.

FATAL EXCEPTION: OkHttp Dispatcher java.lang.NoSuchMethodError: okhttp3.internal.Platform.log 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:1076) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) at java.lang.Thread.run(Thread.java:856)

I am using
gradle
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'

Please help me I searched all over the net

That message indicates you are using a different logger version than the
main okhttp artifact. You can likely fix it by adding an explicit
dependency on OkHttp with the same version as the logger.

On Thu, Aug 25, 2016 at 10:31 AM kiranbjm [email protected] wrote:

FATAL EXCEPTION: OkHttp Dispatcher
java.lang.NoSuchMethodError: okhttp3.internal.Platform.log
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:1076)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)

I am using
_gradle_
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/square/okhttp/issues/1992#issuecomment-242408309, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAEEEYGQFal_Ydt2XXLr4Y9PQx6fFt-wks5qjacwgaJpZM4Ghabg
.

Was this page helpful?
0 / 5 - 0 ratings