I've been working on this issues for a several hours but can't find the solution. Tried a lots of answers from stackoverflow but no luck.

What am I getting is the following gradle error while running the app:

:app:packageAllDebugClassesForMultiDex FAILED
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/widget/SearchViewCompatIcs$MySearchView.class

Android studio throws the error when i add the dependency of ShareThis Sdk into the gradle. Here is the full gradle:

apply plugin: 'com.android.application'

android {
    signingConfigs {
        config {
            keyAlias 'Alies'
            keyPassword 'password'
            storeFile file('path.jks')
            storePassword 'password'
        }
    }
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId "example.com.app"
        minSdkVersion 10
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        preDexLibraries = false
        incremental true
    }
    //configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }
    //configurations { all*.exclude module: 'support-v4' }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    provided files('libs/universal-image-loader-1.9.3.jar')
    compile project(':library-circular')
    compile('com.android.support:appcompat-v7:22.2.0') {
        exclude group: 'com.android.support', module: 'support-v4'
    }
    compile project(':sliding_library1')
    compile('com.google.android.gms:play-services:7.5.0') {
        exclude group: 'com.android.support', module: 'support-v4'
    }
    compile project(':sdk')
}

A small help will be greatly appreciated.

2

There are 2 answers

0
Paresh P. On BEST ANSWER

So, the problem has been resolved. Actually there was a conflict between support-v4 jar files, So I simply used the same support-v4.jar everywhere and the problem is fixed.

0
sandrstar On

Seems the problem is in Compile independent modules in parallel (may require larger heap size). So, disabling that option and clear rebuild should fix it.

Looks like Android Build Tools for multidex sometimes try to include lib project in both dex files and it causes some conflict then compiled simultaneously.