title: Android - MultipartEntity and dependencies
body: <p>I recently migrate my project from Eclipse to Android Studio (I do not fully control this IDE yet). In this project, I have a file uploader AsyncTask which send multipart over http. To do this, I use org.apache.httpcomponents. I created following dependencies:</p>
  
  <pre><code>dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile 'org.apache.httpcomponents:httpcore:4.4'
      compile 'org.apache.httpcomponents:httpmime:4.4'
      ...
  }
  </code></pre>
  
  <hr>
  
  <p>In my java AsyncTask code:</p>
  
  <pre><code>MultipartEntityBuilder builder = MultipartEntityBuilder.create();
  builder.addBinaryBody(...);
  builder.addBinaryBody(...);
  builder.addBinaryBody(...);
  HttpEntity entity = builder.build(); // &lt; throw exception
  </code></pre>
  
  <hr>
  
  <p>The exception I obtain at startup upload:</p>
  
  <pre><code>Caused by: java.lang.NoSuchFieldError: org.apache.http.message.BasicHeaderValueFormatter.INSTANCE
      at org.apache.http.entity.ContentType.toString(ContentType.java:153)
      at org.apache.http.entity.mime.MultipartFormEntity.&lt;init&gt;(MultipartFormEntity.java:52)
      at org.apache.http.entity.mime.MultipartEntityBuilder.buildEntity(MultipartEntityBuilder.java:226)
      at org.apache.http.entity.mime.MultipartEntityBuilder.build(MultipartEntityBuilder.java:230)
  </code></pre>
  
  <hr>
  
  <p>I think there is a conflict between <code>android.jar &gt; httpcomponents</code> and the <code>org.apache.httpcomponents</code> dependency but I don't find a solution to resolve my problem.</p>