1

I am not sure why I am getting this error. Any kind of help will be highly appreciable

Error:Execution failed for task ':packageAllDebugClassesForMultiDex'.

java.util.zip.ZipException: duplicate entry: com/google/zxing/BarcodeFormat.class

heres my app/gradle file

apply plugin: 'android'

dependencies { compile fileTree(include: '*.jar', dir: 'libs') compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.google.android:annotations:4.1.1.4' }

buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:1.3.0' } } allprojects { repositories { jcenter() maven { url "http://releases.payworks.io/artifactory/mpos" } } } android { compileSdkVersion 23 buildToolsVersion '23.0.2' useLibrary 'org.apache.http.legacy'

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

defaultConfig 
{        
    multiDexEnabled true
}
dexOptions {
    javaMaxHeapSize "2g"
}
sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    instrumentTest.setRoot('tests')        
    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
}

repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile 'io.card:card.io:5.0.1@aar'
    compile project(':star')
    compile project(':zxing-android-embedded')
    compile 'io.payworks:mpos.android.ui:2.7.0:@aar'
    compile 'io.payworks:mpos.android.core:2.7.0:@aar'
    compile 'io.payworks:mpos.android.accessories.miura:2.7.0:@aar'
    compile 'io.payworks:mpos.android.comlinks.bluetooth:2.7.0:@aar'
    compile 'io.payworks:mpos.android.accessories.verifone-e105:2.7.0:@aar'
    compile 'io.payworks:mpos.android.comlinks.verifone-e105:2.7.0:@aar'
    compile 'io.payworks:mpos.android.accessories.sewoo:2.7.0:@aar'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.squareup:otto:1.3.5'
    compile 'com.squareup.okhttp:okhttp:2.7.2'
    compile 'com.parse.bolts:bolts-android:1.2.1'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.4.4'
    compile 'com.verifone:verifone-pwmadk:3.0.2@aar'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile 'com.google.android.gms:play-services-identity:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
}
dexOptions {
    preDexLibraries = false
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}
}
Janki Gadhiya
  • 4,492
  • 2
  • 29
  • 59
Ehsan Anjum
  • 762
  • 8
  • 15
  • Possible duplicate of [java.util.zip.ZipException: duplicate entry](http://stackoverflow.com/questions/29872225/java-util-zip-zipexception-duplicate-entry) – Janki Gadhiya Jul 01 '16 at 07:51

1 Answers1

2

I am not sure if it will work, but you could try using a DuplicationStrategy (https://docs.gradle.org/current/javadoc/org/gradle/api/file/DuplicatesStrategy.html) like so:

packageAllDebugClassesForMultiDex {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tomasulo
  • 1,252
  • 8
  • 9
  • where in the gradle should I put that code? Inside android{ }? – Daniel Nazareth Sep 16 '16 at 13:46
  • No, it is a configuration option of a `zip` task. So you have to put it within the task name. – tomasulo Sep 19 '16 at 08:26
  • can you please update your answer with where we need to put this method. – Ajeet Mar 17 '17 at 06:02
  • You add `duplicatesStrategy = DuplicatesStrategy.EXCLUDE` inside of the definition of your zip task. In this example `packageAllDebugClassesForMultiDex` is the name of the task. Does that help you? – tomasulo Mar 17 '17 at 12:32