Okhttp: Caused by: java.lang.IllegalArgumentException: byteCount < 0: -1

Created on 17 May 2017  路  6Comments  路  Source: square/okhttp

error stack

java.lang.reflect.UndeclaredThrowableException
                                                                          at $Proxy2.intercept(Unknown Source)
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
                                                                          at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
                                                                          at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
                                                                          at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
                                                                          at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
                                                                          at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:145)
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
                                                                          at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
                                                                          at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
                                                                          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)
                                                                       Caused by: java.lang.reflect.InvocationTargetException
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.tools.profiler.support.network.OkHttpInterceptorHandler.trackResponseBody(OkHttpInterceptorHandler.java:58)
                                                                          at com.android.tools.profiler.support.network.OkHttpInterceptorHandler.invoke(OkHttpInterceptorHandler.java:39)
                                                                          at java.lang.reflect.Proxy.invoke(Proxy.java:393)
                                                                          at $Proxy2.intercept(Unknown Source)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)聽
                                                                          at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)聽
                                                                          at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)聽
                                                                          at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)聽
                                                                          at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)聽
                                                                          at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:145)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)聽
                                                                          at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)聽
                                                                          at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)聽
                                                                          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)聽
                                                                       Caused by: java.lang.IllegalArgumentException: byteCount < 0: -1
                                                                          at okio.RealBufferedSource.request(RealBufferedSource.java:64)
                                                                          at java.lang.reflect.Method.invoke(Native Method)聽
                                                                          at com.android.tools.profiler.support.network.OkHttpInterceptorHandler.trackResponseBody(OkHttpInterceptorHandler.java:58)聽
                                                                          at com.android.tools.profiler.support.network.OkHttpInterceptorHandler.invoke(OkHttpInterceptorHandler.java:39)聽
                                                                          at java.lang.reflect.Proxy.invoke(Proxy.java:393)聽
                                                                          at $Proxy2.intercept(Unknown Source)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)聽
                                                                          at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)聽
                                                                          at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)聽
                                                                          at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)聽
                                                                          at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)聽
                                                                          at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:145)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)聽
                                                                          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)聽
                                                                          at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)聽
                                                                          at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)聽
                                                                          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)聽

gradle : com.android.tools.build:gradle:2.4.0-alpha7
okhttp version: 3.8.0
make post http request.
url: http://106.14.57.254/v1/postSms
field:
"phone":"18200389404"

Most helpful comment

@lujop I was able to fix it by going into my Run/Debug Configuration > Profiling, and disabling the Enable Advanced Profiling

All 6 comments

Looks like a bug in com.android.tools.profiler.support.network.OkHttpInterceptorHandler.trackResponseBody(OkHttpInterceptorHandler.java:58).

A few days ago after updating OKHttp I notice the same issue. It's very weird because when I removed app and install once again through Android Studio, app started working fine.
I've used Android Studio 2.4 prev7
gradle: 2.4.0-alpha7
okhttp: 3.8.0

This seems to be connected with the new Android Studio network profiling feature - it only shows up when the advanced profiling is enabled (Android Studio 2.4+ and Gradle Plugin 2.4.0 preview).

Anyone knows if profiling can be disabled or any workarround that allows to continue with Android Studio 2.4?
And if this possible problem has been reported to android tools?

@lujop I was able to fix it by going into my Run/Debug Configuration > Profiling, and disabling the Enable Advanced Profiling

The previous comment has the workaround. No further action for us to take on this.

Was this page helpful?
0 / 5 - 0 ratings