1

I am getting this error

Error:Execution failed for task ':yourapp:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v7/recyclerview/BuildConfig.class

Here is my build.gradle file

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.test"
        minSdkVersion 15
        multiDexEnabled true
        targetSdkVersion 22
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

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

dependencies {
    compile (project(':library_slidingmenu')) {
    exclude group: 'com.android.support', module: 'recyclerview-v7'
}
    compile project(':library')
    compile 'com.android.support:appcompat-v7:22.2.1'
    androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
    compile 'org.projectlombok:lombok:1.16.6'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.android.support:cardview-v7:22.1.0'
    compile 'com.android.support:recyclerview-v7:22.1.0'

Any idea how to solve it?

Soham
  • 4,397
  • 11
  • 43
  • 71
  • Someone have already answered...Check [this](http://stackoverflow.com/questions/26718825/how-to-resolve-java-util-zip-zipexception) – roccocullo Oct 28 '15 at 13:43
  • @roccocullo.Two errors are not exactly same. – Soham Oct 28 '15 at 13:47
  • Please post the results of `gradle androidDependencies`. You have conflicting dependencies and probably need to exclude a module but without the dependency graph its hard to say which – JBirdVegas Oct 28 '15 at 16:53
  • Are you including `compile 'com.android.support:recyclerview-v7:22.1.0'` as a dependency in either `project(':library_slidingmenu')` or `project(':library')`? – JBirdVegas Oct 28 '15 at 17:03
  • @JBirdVegas one of the library has dependency of `recyclerview` – Soham Oct 29 '15 at 05:29
  • @Soham I think that's enough info to solve the problem. See my answer – JBirdVegas Oct 29 '15 at 05:39

1 Answers1

0

If you have a dependency that also declares the recyclerview lib then just exclude it from the dependency. For example imagine your lib library_slidingmenu contains the recyclerview dependency, then we would need to do something like this

dependencies {
    compile project(':library_slidingmenu') {
        exclude group: 'com.android.support', module: 'recyclerview-v7'
    }
    // the rest of your dependecies
}
JBirdVegas
  • 10,855
  • 2
  • 44
  • 50
  • Then more info is needed post the results `gradle androidDependencies` as previously asked – JBirdVegas Oct 29 '15 at 12:22
  • 1
    By the way one thing has been solved,that it's not repeating.Sometimes I have to clean and build it again,then it's running.So I am accepting your answer. – Soham Oct 29 '15 at 12:31