Org.Apache.Http.Entity.Fileentity Is Deprecated in Android 6 (Marshmallow)

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.

HTTP not working in Android 6.0

You can not use HttpPost or Httpclient in android 6.0.
Android 6.0 release removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API level 9) or higher, use the HttpURLConnection class instead.

apache http imports not working

Try to add org.apache.http.legacy.jar to your libs folder.

You can find this jar in Android/Sdk/platforms/android-23/optional

Add this line to your app.gradle file

compile fileTree(dir: 'libs', include: ['*.jar'])

And delete useLibrary 'org.apache.http.legacy'

This way Im using library without any problem

How to fix package: org.apache.http doesn't exist

To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:

 android {
useLibrary 'org.apache.http.legacy'
}

Look the Image :

Sample Image



Related Topics



Leave a reply



Submit