3

I'm using android studio version 0.5.8

I'm using httpclient-android together with httpmime to send post data to an http url.

my build.gradle file:

apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
     }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.google.android.gms:play-services:+'
    compile 'org.apache.commons:commons-lang3:3.3.2'
    compile 'org.apache.httpcomponents:httpclient-android:4.3.3'
    compile 'org.apache.httpcomponents:httpmime:4.3.3'
}

i get the following error

Error:Execution failed for task ':myalcoholist:packageDebug'.
> Duplicate files copied in APK META-INF/NOTICE
File 1: /home/ufk/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.3/e02368d7b56c0c376f227378a4f77de62864d020/httpmime-4.3.3.jar
File 2: /home/ufk/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.3/e02368d7b56c0c376f227378a4f77de62864d020/httpmime-4.3.3.jar

I tried to delete .grandle directory and sync grandle but i still get the same error.

any ideas?

ufk
  • 30,912
  • 70
  • 235
  • 386

1 Answers1

5

Add this:

android {
    packagingOptions {
        exclude 'META-INF/NOTICE'
    }
}

If you get any more of these errors, just add it on a separate line.

nhaarman
  • 98,571
  • 55
  • 246
  • 278
  • Can you please tell me what we are doing when we add this line and explain to me how this actually helps fix the issue? It definitely does fix the issue, I just don't know why. – Simon Oct 11 '14 at 19:52