当前位置:   article > 正文

错误 com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: closed 解决方案_caused by: com.google.gson.jsonsyntaxexception: ja

caused by: com.google.gson.jsonsyntaxexception: java.lang.illegalstateexcept

Retrofit 的使用参考,可以在这里查看 http://blog.csdn.net/aka_GZ/article/details/52447777


按照网上配置请求之并未成功拿到数据,

查看错误信息后发现出现这个异常 com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: closed


经过排查,原因是因为在拦截器里面  ,打印了请求体,有说法是, response.body() 只能调用一次,再次调用会出现状态异常

看来想打印请求信息,需要另求它法了

//网络拦截器
client.networkInterceptors().add(new Interceptor() {
    @Override
    public com.squareup.okhttp.Response intercept(Chain chain) throws IOException {
        Request request=chain.request();
        com.squareup.okhttp.Response response = chain.proceed(request);

        Log.e("weiquan",""+request.httpUrl()+" "+request.headers()+"  "+response.body().string());
        return response;
    }

});




声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/246348
推荐阅读
相关标签
  

闽ICP备14008679号