Retrofit使用过程中遇到的问题2.0

来源:互联网 发布:windows网络监控工具 编辑:程序博客网 时间:2024/05/21 05:55

Retrofit2.0使用过程中遇到的问题

Retrofit在进行异步的网络请求时,代码如下:

Call<Post_BeaconResult> call = api.PostForm_foots(foots, share_get_loginticket, ts, qianmingcode);call.enqueue(new Callback<Post_BeaconResult>() {    @Override    public void onResponse(Call<Post_BeaconResult> call, Response<Post_BeaconResult> response)    {        String s = response.body().toString();    }    @Override    public void onFailure(Call<Post_BeaconResult> call, Throwable t) {        LogUtil.d("&&&&&错误", t.getMessage().toString());    }});
可能会抛出异常:RETROFIT: Use JsonReader.setLenient(true) to accept malformed JSON at line 1

我的解决办法是:在Module:app中添加

compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'

0 0
原创粉丝点击