添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

AndroidStudio_A connection was leaked. Did you forget to close a response body?---Android原生开发工作笔记240

下面是报错内容,使用okhttp,的时候报错的.这个不关闭,好像时间久了会报内存溢出错误.

W/OkHttp: A connection to http://172.19.128.64:8061/ was leaked. Did you forget to close a response body?

比如,下面这样解决:

//4.同步人脸库操作
    private void faceAsync() {
        //1.这里去同步照片到人脸库
        //String faceUrl="http://172.19.128.73:8060/api/faceDevice/listByIp";
        String  server_ip = GetConfigValue.getConfigProperties("server_ip");
        //String faceUrl="http://172.19.128.64:8061/api/faceDevice/listByIp";
        String faceUrl=server_ip + "/api/faceDevice/listByIp";
        OkHttpClient faceHttpClient = new OkHttpClient();
        Request faceRequest = new Request.Builder()
                .get()
                .url(faceUrl)
                .build();
        //构造Call对象
        Call faceCall=faceHttpClient.newCall(faceRequest);
        faceCall.enqueue(new Callback() {
            @Override
            public void onFailure(