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 :
Related Topics
Is There a Java Equivalent or Methodology For the Typedef Keyword in C++
View'S Getwidth() and Getheight() Returns 0
How to Display Data from Firestore in a Recyclerview With Android
Why Do I Get "Failed to Bounce to Type" When I Turn Json from Firebase into Java Objects
How to Stop Repeated Keypressed()/Keyreleased() Events in Swing
Calling Awt Frame Methods from Subclass
How to Retrieve and Display Images from a Database in a Jsp Page
Unsupported Major.Minor Version 52.0
Why Is 128==128 False But 127==127 Is True When Comparing Integer Wrappers in Java
Calling a Java Method from C++ in Android
How to Get Url from Firebase Storage Getdownloadurl
After Google Play Service Update to Version 13 I Got an Error
Failed to Resolve Com.Google.Android.Gms Play-Services-Auth:11.4.0
Relation Between Memory Host and Memory Arguments Xms and Xmx from Java
What Issues Should Be Considered When Overriding Equals and Hashcode in Java