title: Importing a newer Apache HttpClient jar in Android
body: <p>I'm trying to send an HTTP/HTTPS post request from my Android client.</p>
  
  <h2>Question</h2>
  
  <p>Why does my code fail?</p>
  
  <h2>So far</h2>
  
  <p>I created an apache class/HttpClient call. Everything worked fine:</p>
  
  <pre><code>HttpClient httpClient = new DefaultHttpClient();
  </code></pre>
  
  <p>I've read that this method has been deprecated, so I've switched to the new recommended method:</p>
  
  <pre><code>HttpClient httpClient = HttpClientBuilder.create().build();
  </code></pre>
  
  <p>Eclipse didn't have this class, so I had to download Apache HttpClient 4.3.3. I imported it to my project by copying it into the <code>libs</code> folder and adding them to my build path (imported httpclient, httpclient-cache, httpcore, httpmime, fluent-hc, commons-logging, commons-codec).</p>
  
  <h2>Error message</h2>
  
  <pre><code>06-05 02:15:26.946: W/dalvikvm(29587): Link of class 'Lorg/apache/http/impl/conn/PoolingHttpClientConnectionManager;' failed
  06-05 02:15:26.946: E/dalvikvm(29587): Could not find class 'org.apache.http.impl.conn.PoolingHttpClientConnectionManager', referenced from method org.apache.http.impl.client.HttpClientBuilder.build
  </code></pre>
  
  <h2>Most recent code</h2>
  
  <pre><code>static private String insertJson(String json,String url){
      HttpClient httpClient = HttpClientBuilder.create().build();
  
      String responseString = "";
      try {
          HttpPost request = new HttpPost(url);
          StringEntity params =new StringEntity(json, "UTF-8");
          request.addHeader("content-type", "application/json");
          request.setEntity(params);
          HttpResponse response = httpClient.execute(request);
          HttpEntity entity = response.getEntity();
          responseString = EntityUtils.toString(entity, "UTF-8");
  
      }catch (Exception ex) {
          ex.printStackTrace();
          // handle exception here
      } finally {
          httpClient.getConnectionManager().shutdown();
      }
      return responseString;
  }
  </code></pre>