0

My gradle file is

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "24.0.0 rc2"

defaultConfig {
    applicationId "com.test.test"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

buildscript {
repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}

repositories {
mavenCentral()
jcenter()
flatDir {
    dirs '../libs'
}
}



dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
compile('com.google.android.gms:play-services:8.4.0') {
    exclude group: 'com.google.guava'
}
compile ('org.apache.httpcomponents:httpcore:4.4.4')
        {
            exclude group: 'org.apache.http.annotation.NotThreadSafe'
        }
compile 'commons-io:commons-io:2.4'
compile 'com.android.support:support-annotations:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.google.android.exoplayer:exoplayer:r1.4.2'
compile 'com.mopub.volley:mopub-volley:1.1.0'
compile 'com.android.support:multidex:1.0.0'
}

And I am getting this error while compiling the application

Error:Execution failed for task ':myapplication:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/annotation/NotThreadSafe.class

Can anyone please tell me what I need to exclude from the dependency list. Or any solution for the problem ?

Viral Thakker
  • 547
  • 2
  • 10

3 Answers3

0

Take care if you have other subproject included. You can probably fix it by adding in your "proguard-rules.pro" the following exception :

-dontwarn org.apache.**
tryp
  • 1,120
  • 20
  • 26
0

Modify your gradle like this:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "24.0.0 rc2"

defaultConfig {
    applicationId "com.test.test"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/notice.txt'
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

buildscript {
repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}

repositories {
mavenCentral()
jcenter()
flatDir {
    dirs '../libs'
}
}



dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
compile('com.google.android.gms:play-services:8.4.0') {
    exclude group: 'com.google.guava'
}
compile ('org.apache.httpcomponents:httpcore:4.4.4')
        {
            exclude group: 'org.apache.http.annotation.NotThreadSafe'
        }
compile 'commons-io:commons-io:2.4'
compile 'com.android.support:support-annotations:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.google.android.exoplayer:exoplayer:r1.4.2'
compile 'com.mopub.volley:mopub-volley:1.1.0'
compile 'com.android.support:multidex:1.0.0'
}

the packagingOptions will let you use duplicate classes. That means if two libraries having same class names then compiler will ignore that.

Janki Gadhiya
  • 4,492
  • 2
  • 29
  • 59
-1

Clean project and then build again .duplicate entry error will resolve.

  • compile ('com.octo.android.robospice:robospice-retrofit:1.4.13') { exclude group: 'org.apache.commons', module: 'commons-io' } compile 'commons-io:commons-io:1.3.2' try this viral – AndroidSter Apr 29 '16 at 05:11