Can not resolve org.apache.http.entity.mime.MultipartEntity , HttpMultipartMode

Avinash Das picture Avinash Das · Jul 19, 2016 · Viewed 14.6k times · Source

Snapshot of Android Studio screen

Snapshot of error messages inside Android Studio

I followed the suggestions mentioned here but could not resolve the errors.How to add external dependencies (jar file) to android studio?

Please suggest what am I missing here?

1: enter image description here

1: enter image description here

Answer

Prashant picture Prashant · Jul 19, 2016

1) add this line to android tag of your build.gradle file

useLibrary 'org.apache.http.legacy'

it will look like after adding this line :

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    useLibrary 'org.apache.http.legacy'

Please check this link to know why you need to add this : https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client

2) if you have downloaded jar already skip this step, i have seen in screenshot that you have already added it to your build.gradle file.

download this file and extract jar from it. http://www.java2s.com/Code/JarDownload/httpmime/httpmime-4.1.1.jar.zip

and add this library to your library folder. now right click on that jar file and click on the option "Add As Library..."

this should work