在这一段中我不断得到错误&canot解决符号(和方法)'

时间:2016-04-07 12:15:02

标签: java android

这是我在整个应用程序中遇到的唯一问题。

enter image description here

3 个答案:

答案 0 :(得分:1)

HttpClient was deprecated in API Level 22 and has been removed in API Level 23。您必须使用<picture> <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/652/coffee5.jpg" srcset="https://s3-us-west-2.amazonaws.com/s.cdpn.io/652/coffee5.jpg" data-pin-description="Hello World"> </picture>

如果您在API 23中仍然需要,请将其添加到您的URLConnection

build.gradle

注意:相反,我建议使用OkHttp

答案 1 :(得分:0)

试试这个......

     InputStream irs;
     URL url = new URL("**your URL**");

try{
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setReadTimeout(30000);
    conn.setConnectTimeout(45000);
    conn.setRequestMethod("GET");
    conn.setDoInput(true);
    // Starts the query
    conn.connect();
    irs = conn.getInputStream();
    }catch(Exception e)
      {
          e.printStactTrace();
      }

答案 2 :(得分:0)

请导入这些课程。

可能会弃用 所以请将它添加到您的构建文件

依赖项{

编译文件(&#39; libs / org.apache.http.legacy.jar&#39;)

}