java – 执行httpclient时出现奇怪的错误

I have created an http request in my project. I sat it but didn’t work
so simplified that part to test it: This is it:

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());
    }

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

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

And of course a “Didn’t work!” and a “null” for prints! I appreciate
your tips Tnx

解决方法

你知道HttpClient被弃用了吗?

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

您的例外可能是API不再受支持的结果.

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...