执行httpclient时出现奇怪的错误

A_K*_*_Kz 7 java android httpclient httprequest

我在我的项目中创建了一个http请求.我坐着它但是没有那么简单的部分来测试它:这就是它:

HttpClient cl = new DefaultHttpClient();
    try {
        HttpResponse httpResponse = cl.execute(new HttpGet("http://www.google.com"));
        System.out.println(httpResponse.getEntity().getContentLength());
    }
    catch (Exception e)
    {
        System.out.println("didn't work!");
        System.out.println(e.getMessage());
    }
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时我会得到这些:

07-21 15:57:36.203  26851-26851/com.akgradev.upbman W/? Unable to open '/system/framework/qcom.fmradio.jar': No such file or directory
07-21 15:57:36.203  26851-26851/com.akgradev.upbman W/art? Failed to open zip archive '/system/framework/qcom.fmradio.jar': I/O Error
Run Code Online (Sandbox Code Playgroud)

当然是"没有用!" 印刷品的"空"!我感谢你的提示Tnx

小智 0

您知道自己HttpClient被弃用了吗?

https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client

您的异常可能是由于 API 不再受支持而导致的。