Mysterious Mysterious - 2 months ago 30
Java Question

Android: Error:Execution failed for task ':app:transformClassesWithJarMergingForFlavorDebug'

Hi am facing the following error in Android Studio ..


Error:Execution failed for task
':app:transformClassesWithJarMergingForFlavorDebug'.


com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
com/google/zxing/aztec/AztecDetectorResult.class



Project was working fine but I dont know why it start giving this exception .. I did not changed anything in gradle file..

gradle File:

apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias 'Project'
keyPassword 'password'
storeFile file('./../project/project.keystore')
storePassword 'password'
}
}
compileSdkVersion 25
buildToolsVersion '25.0.2'
useLibrary 'org.apache.http.legacy'
lintOptions {
checkReleaseBuilds false
}
dexOptions {
jumboMode = true
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.project.project"
minSdkVersion 15
targetSdkVersion 25
versionCode 38
versionName "2.1.0"
multiDexEnabled true
signingConfig signingConfigs.config
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
signingConfig signingConfigs.config
}
}
productFlavors {
flavor {
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/AndroidSwipeLayout-v1.1.8.jar')
compile files('libs/commons-codec-1.3.jar')
compile files('libs/httpmime-4.3.5.jar')
compile files('libs/linkedin-j-android.jar')
compile files('libs/localytics.jar')
compile files('libs/picasso-2.5.2.jar')
compile files('libs/retrofit-1.9.0.jar')
compile files('libs/twitter4j-core-4.0.1.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
compile files('libs/zxing-2.1.jar')
compile files('libs/bolts-android-1.1.2.jar')
compile('com.facebook.android:facebook-android-sdk:[4,5)') {
exclude module: 'bolts-android'
exclude module: 'com.android.support:support-v4:23.0.3'
}
// compile 'com.kbeanie:image-chooser-library:1.6.0@aar'
// compile 'com.kbeanie:image-chooser-library:1.5.8@aar'
compile files('libs/isoparser-1.0-RC-27.jar')
compile files('libs/aspectjrt-1.8.7.jar')
compile project(':image-chooser-library')
compile 'com.google.code.gson:gson:2.7'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android.gms:play-services-auth:10.2.1'
compile 'com.google.android.gms:play-services-gcm:10.2.1'
compile 'com.google.android.gms:play-services-plus:10.2.1'
compile 'com.appsflyer:af-android-sdk:4.+@aar'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'javax.media:jmf:2.1.1e'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}


I am using;


Windows 8.1 pro,
Android Studio 2.3.3


What i Tried till now;



  1. Clean Build Rebuild

  2. gradlew clean

  3. Delete Both build folders




Nothing worked

Can please someone help me .. if any other information required please let me know

Answer Source

If you are not using flavours then just remove the flavour section in gradle

apply plugin: 'com.android.application'
android {
    signingConfigs {
        config {
            keyAlias 'Project'
            keyPassword 'password'
            storeFile file('./../project/project.keystore')
            storePassword 'password'
        }
    }
    compileSdkVersion 25
    buildToolsVersion '25.0.2'
    useLibrary 'org.apache.http.legacy'
    lintOptions {
        checkReleaseBuilds false
    }
    dexOptions {
        jumboMode = true
        javaMaxHeapSize "4g"
    }
    defaultConfig {
        applicationId "com.project.project"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 38
        versionName "2.1.0"
        multiDexEnabled true
        signingConfig signingConfigs.config
    }
    buildTypes {
        release {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        debug {
            signingConfig signingConfigs.config
        }
    }
  // comenting the flavour section 
  //  productFlavors {
  //     flavor {
  //      }
  // }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/AndroidSwipeLayout-v1.1.8.jar')
    compile files('libs/commons-codec-1.3.jar')
    compile files('libs/httpmime-4.3.5.jar')
    compile files('libs/linkedin-j-android.jar')
    compile files('libs/localytics.jar')
    compile files('libs/picasso-2.5.2.jar')
    compile files('libs/retrofit-1.9.0.jar')
    compile files('libs/twitter4j-core-4.0.1.jar')
    compile files('libs/universal-image-loader-1.9.3.jar')
    compile files('libs/zxing-2.1.jar')
    compile files('libs/bolts-android-1.1.2.jar')
    compile('com.facebook.android:facebook-android-sdk:[4,5)') {
        exclude module: 'bolts-android'
        exclude module: 'com.android.support:support-v4:23.0.3'
    }
    //    compile 'com.kbeanie:image-chooser-library:1.6.0@aar'
    //    compile 'com.kbeanie:image-chooser-library:1.5.8@aar'
    compile files('libs/isoparser-1.0-RC-27.jar')
    compile files('libs/aspectjrt-1.8.7.jar')
    compile project(':image-chooser-library')
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.google.android.gms:play-services-auth:10.2.1'
    compile 'com.google.android.gms:play-services-gcm:10.2.1'
    compile 'com.google.android.gms:play-services-plus:10.2.1'
    compile 'com.appsflyer:af-android-sdk:4.+@aar'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'javax.media:jmf:2.1.1e'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}