问题是标题所说的。它仅在某些时间和某些电话出现。听见是我抓到的日志。
java.lang.IllegalStateException
closed
okio.RealBufferedSink.write(RealBufferedSink.java:44)
okio.ForwardingSink.write(ForwardingSink.java:35)
com.******.******.network.UploadRequestBody$1.write(UploadRequestBody.java:75)
okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
okio.RealBufferedSink.writeAll(RealBufferedSink.java:104)
com.squareup.okhttp.RequestBody$3.writeTo(RequestBody.java:118)
com.squareup.okhttp.MultipartBuilder$MultipartRequestBody.writeOrCountBytes(MultipartBuilder.java:277)
com.squareup.okhttp.MultipartBuilder$MultipartRequestBody.writeTo(MultipartBuilder.java:297)
com.******.******.network.UploadRequestBody.writeTo(UploadRequestBody.java:59)
com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:718)
com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:576)
com.squareup.okhttp.Call.getResponse(Call.java:287)
com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
com.squareup.okhttp.Call.access$100(Call.java:35)
com.squareup.okhttp.Call$AsyncCall.execute(Call.java:171)
com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
java.lang.Thread.run(Thread.java:848)
您介意帮助我并告诉他们如何避免吗?
最佳答案
我在github issue上找到了这个
您只能拨打response.body().string()
一次。
关于android - 使用OkHttp上传文件,但发生java.lang.IllegalStateException:在okio.RealBufferedSink.write(RealBufferedSink.java:44)关闭,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37319124/