title: How to add Apache HTTP API (legacy) as compile-time dependency to build.grade for Android M?
body: <p>As mentioned <a href="http://developer.android.com/preview/behavior-changes.html#behavior-apache-http-client" rel="noreferrer">here</a>, Android M will not support the Apache HTTP API.  The docs state to:</p>
  <blockquote>
  <p>use the HttpURLConnection class instead.</p>
  </blockquote>
  <p>or</p>
  <blockquote>
  <p>To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:</p>
  <p>android { useLibrary 'org.apache.http.legacy'
  }</p>
  </blockquote>
  <p>I have converted much of my project's usage of HttpClient to HttpURLConnection, however, I still <em>need</em> to use the HttpClient in a few areas.  Hence, I am trying to declare 'org.apache.http.legacy' as a compile-time dependency but am getting an error in build.gradle:</p>
  <blockquote>
  <p>Gradle DSL method not found: 'useLibrary()'</p>
  </blockquote>
  <p>My question is: how do I declare 'org.apache.http.legacy' as a compile-time dependency in my project?</p>
  <p>Any help is much appreciated.  Thanks</p>