I am working on an app which requires the use of MultipartEntityBuilder. To use this I have included org.apache.httpcomponents:httpmime:4.4
Here is the code snippet from the app:
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addPart("file", new FileBody(new File(filePath)));
builder.addTextBody("type", type);
builder.addTextBody("phone", pPhoneNumber);
Now the issue is, FileBody here requires ContentType class which is included in org.apache.httpcomponents:httpcore. But if I import this in Gradle, I am unable to proceed with compile due to conflict with internal version of provided by Android. I am getting following error:
Error:duplicate files during packaging of APK /somepath/app/build/outputs/apk/app-debug-unaligned.apk
Path in archive: META-INF/DEPENDENCIES
Origin 1: /Users/Sachin/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.4/54646f004d5b4c37a5a75b1d416c59a3075204e2/httpmime-4.4.jar
Origin 2: /Users/Sachin/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.4.1/f5aa318bda4c6c8d688c9d00b90681dcd82ce636/httpcore-4.4.1.jar
Please suggest a solution.