0

I get this error when I try to run my application:

Information:Gradle tasks [:app:assembleDebug] Warning:Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:compileDebugNdk UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72200Library UP-TO-DATE :app:prepareComAndroidSupportRecyclerviewV72200Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42200Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:compileDebugJava UP-TO-DATE :app:preDexDebug UP-TO-DATE :app:dexDebug UP-TO-DATE :app:processDebugJavaRes UP-TO-DATE :app:validateDebugSigning :app:packageDebug Error:duplicate files during packaging of APK /Users/.../app/build/outputs/apk/app-debug-unaligned.apk Path in archive: META-INF/NOTICE Origin 1: /Users/.../.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient-android/4.3.5/82edcaec6c7b4599eaeaaf11167ceea41db42f33/httpclient-android-4.3.5.jar Origin 2: /Users/.../.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.5/1dd0d38df9c6d21e893f2e52403f1cd99e91cd81/httpmime-4.3.5.jar You can ignore those files in your build.gradle: android { packagingOptions { exclude 'META-INF/NOTICE' } } Error:Execution failed for task ':app:packageDebug'. > Duplicate files copied in APK META-INF/NOTICE File 1: /Users/.../.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient-android/4.3.5/82edcaec6c7b4599eaeaaf11167ceea41db42f33/httpclient-android-4.3.5.jar File 2: /Users/.../.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient-android/4.3.5/82edcaec6c7b4599eaeaaf11167ceea41db42f33/httpclient-android-4.3.5.jar Information:BUILD FAILED Information:Total time: 2.754 secs Information:2 errors Information:2 warnings Information:See complete output in console 

Here is my build.gradle:

apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "..." minSdkVersion 14 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.0.0' compile 'com.android.support:support-v4:22.0.0' compile 'com.squareup.retrofit:retrofit:1.9.0' compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5' compile (group: 'org.apache.httpcomponents' , name: 'httpmime' , version: '4.3.5') { exclude module: 'org.apache.httpcomponents:httpclient' } } 

I simply want to import the following libraries:

import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.mime.MultipartEntity; import org.apache.http.entity.mime.content.ContentBody; import org.apache.http.entity.mime.content.FileBody; import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.json.JSONObject; 

so I can run the following code:

 String sendProfileData = getResources().getString(R.string.URL); DefaultHttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(sendProfileData); MultipartEntity mpEntity = new MultipartEntity(); try { mpEntity.addPart("first_name", new StringBody("Jay")); mpEntity.addPart("last_name", new StringBody("Shmidt")); ... } ... 

What exactly is wrong here - Do I actually need to delete or replace jar files? Why isn't gradle taking care of this?

Any advice would be really helpful. Thanks in advance!

2 Answers 2

1

Update: I got the answer from this post

Android Gradle plugin 0.7.0: "duplicate files during packaging of APK"

android { packagingOptions { exclude 'META-INF/DEPENDENCIES.txt' exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/dependencies.txt' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/license.txt' exclude 'META-INF/LGPL2.1' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/notice.txt' } } 
Sign up to request clarification or add additional context in comments.

Comments

0

Thats not problem in Android Studio only your system require internet connection

  1. Just extends class MultipartEntity
  2. Than press Alt+Enter
  3. Than click find jar on web
  4. Select httpmime-4.0-alpha4.jar
  5. Than right click on project structure
  6. Click open module setting
  7. In dependencies tab click on + icon on right side
  8. Than click on file dependency select http:mime file added
  9. Finally build project

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.