org.apache.http.entity.FileEntity is deprecated in Android 6 (Marshmallow)

If you change your compileSdkVersion to 21, your app will compile cleanly. That being said, there are reasons why Google is backing away from the built-in HttpClient implementation, so you probably should pursue some other library. That
“some other library” could be:

  • the built-in classic Java HttpUrlConnection, though as you have found, its API leaves something to be desired
  • Apache’s independent packaging of HttpClient for Android
  • OkHttp (my recommendation)
  • AndroidAsync

In particular, OkHttp seems to have a pretty good API for posting a file and posting a multipart form, which should be similar to what your HttpClient code is doing.

Leave a Comment