3

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':transformClassesWithJarMergingForDebug'.

    com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/content/Loader$OnLoadCompleteListener.class

Code in build.gradle file

   apply plugin: 'com.android.application'


dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    //compile project(':ActionBarSherlock-4.1.0')
    compile project(':GooglePlayServicesLibrary')
    compile files('libs/eventbus-2.4.0.jar')
    compile (project(':AndroidBetterPickers')){ exclude module: 'support-v4' }
    compile (project(':ZxingFragmentLib')){ exclude module: 'support-v4' }
    compile (project(':RobotoTextView')){ exclude module: 'support-v4' }
    compile (project(':PanesLibrary')){ exclude module: 'support-v4' }
    compile (project(':ShowCaseViewLibrary')){ exclude module: 'support-v4' }
    compile (project(':ActionBarSherlock-4.1.0')){ exclude module: 'support-v4' }



}

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.3'
    }



}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
}



android {
    packagingOptions {

        exclude  'META-INF/maven/com.nineoldandroids/library/pom.xml'
        exclude  'META-INF/maven/com.nineoldandroids/library/pom.properties'
        exclude  'META-INF/services/javax.annotation.processing.Processor'

    }



    dexOptions {
        javaMaxHeapSize "4g"
    }
    compileSdkVersion 19
    buildToolsVersion '22.0.1'

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 15
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }




    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['.apt_generated','res','src']
            resources.srcDirs = ['.apt_generated','res','src']
            aidl.srcDirs = ['.apt_generated','res','src']
            renderscript.srcDirs = ['.apt_generated','res','src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }




}
SUNIL GOWROJI
  • 123
  • 1
  • 1
  • 10

3 Answers3

7

I've done it like this

dependencies {
    api('com.android.support:recyclerview-v7:22.2.0') {
       exclude module: 'support-v4'
    }
 }
vincent091
  • 2,245
  • 4
  • 15
  • 21
San Droid
  • 322
  • 1
  • 7
  • i have done the same to all the libraries which as it support. but that couldn't helped me. – SUNIL GOWROJI Sep 05 '16 at 14:06
  • note that the google play service api is [very big] (https://developers.google.com/android/guides/setup) perhaps you need only some apis. Back to you problem: try the command gradle dependencies. This will display project dependencies in a tree format. – San Droid Sep 05 '16 at 14:15
  • +--- project :GooglePlayServicesLibrary +--- project :AndroidBetterPickers +--- project :ZxingFragmentLib +--- project :RobotoTextView +--- project :PanesLibrary | \--- project :ActionBarSherlock-4.1.0 +--- project :ShowCaseViewLibrary \--- project :ActionBarSherlock-4.1.0 below is the tree for gradle dependencies – SUNIL GOWROJI Sep 05 '16 at 15:29
  • some of the libraries also use support v4 jar as a dependency in it. Was that the issue with the libraries? – SUNIL GOWROJI Sep 05 '16 at 16:44
  • With gradle dependencies you can identify which library use/require support v4. So if you done this you can exlude the support v4 on this library like you done it before e.g. compile (project(':GooglePlayServicesLibrary')) {exclude module: 'support-v4'} – San Droid Sep 06 '16 at 07:36
0

I got the same problem, after reset implementation to compile, it works fine, but I don't know why..... maybe it's a bug of 'implementation'

LenaYan
  • 736
  • 6
  • 7
0
dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    // compile project(':ActionBarSherlock-4.1.0')
    compile project(':GooglePlayServicesLibrary')
    compile files('libs/eventbus-2.4.0.jar')
    compile (project(':AndroidBetterPickers'))
    compile (project(':ZxingFragmentLib'))
    compile (project(':RobotoTextView'))
    compile (project(':PanesLibrary'))
    compile (project(':ShowCaseViewLibrary'))
    compile (project(':ActionBarSherlock-4.1.0'))
compile files('libs/support-v4-19.0.1.jar')
Sergey Kalinichenko
  • 675,664
  • 71
  • 998
  • 1,399