0

I try to build project and get this error:

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

java.io.IOException: Can't write [C:\Users\Igor\Documents\AndroidStudioProjects\MosaicPicture\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\Igor.gradle\caches\transforms-1\files-1.1\recyclerview-v7-26.1.0.aar\8f92a0a82aeead91e034e3a46e1f2a6c\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/v7/widget/RecyclerView$ItemAnimator.class]))

Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "ru.snoitacilppa.mosaicpicture"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 8
        versionName "1.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:exifinterface:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.google.android.gms:play-services-ads:11.8.0'
    compile 'com.google.android.gms:play-services-location:11.8.0'
    compile project(':adcolony-sdk-3.1.2')
}

I tried to clean and rebuild project, but it didn't help me

What's wrong?

mtrfnv
  • 63
  • 8
  • you can try removing ` implementation 'com.android.support:recyclerview-v7:26.1.0' ? because its already in `com.android.support:appcompat-v7:26.1.0` – karandeep singh Feb 13 '18 at 21:05
  • @karandeepsingh java.lang.RuntimeException: Unable to resume activity {ru.snoitacilppa.mosaicpicture/ru.snoitacilppa.mosaicpicture.MainActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.v7.widget.RecyclerView – mtrfnv Feb 13 '18 at 21:15
  • do you have any jar files as well in your project? – karandeep singh Feb 13 '18 at 21:18
  • @karandeepsingh yes. i have .jar files which is assotiated with Appodeal – mtrfnv Feb 13 '18 at 21:30

1 Answers1

0

Updated Solution:

According to this accepted answer and as per the comments, removing recycler-view library from libs resolves the error.


This error mainly occurs when you include libraries in your project and some of those libraries contain common dependencies with the other included libraries of the project and this is why Proguard fails with a Duplicate Zip Entry Exception.

The accepted answers here or here should help you to resolve your error.

Dhara Bhavsar
  • 345
  • 4
  • 11
  • I do not understand. What do I need to do specifically in my case? I tried add packagingOptions { exclude 'android/support/v7/widget/RecyclerView$ItemAnimator.class' } but error has remained – mtrfnv Feb 14 '18 at 14:08
  • As per the updated gradle functions _compile_ is deprecated, hence could you update the last three dependencies being included using **compile** to **implementation** and check what errors you are getting? You can refer [this answer](https://stackoverflow.com/a/44493379/) to update it accurately. – Dhara Bhavsar Feb 14 '18 at 16:34
  • Could you also update `packagingOptions` added with the following `packagingOptions { exclude "META-INF/MANIFEST.MF" exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/license.txt' exclude 'META-INF/notice.txt' }` and let me know what error you are getting. – Dhara Bhavsar Feb 14 '18 at 16:38
  • I also think `{exclude 'android/support/v7/widget/RecyclerView$ItemAnimator.class' }` should be applied to the library/libraries that are depending on the above class. As an example, `implementation ('org.apache.httpcomponents:httpcore:4.4.4') { exclude group: 'org.apache.http.annotation.NotThreadSafe' } ` as per second comment on [this answer](https://stackoverflow.com/a/46950942/) – Dhara Bhavsar Feb 14 '18 at 16:45
  • my gradle-file after changes: https://gist.github.com/mtrfnv1/758b6ea8827b71c07278d52d35d23acb I'm not sure I wrote `exclude` in the right place. Using this variant, the error remained the same – mtrfnv Feb 14 '18 at 18:27
  • 1
    Yes I was not hoping your issue to be resolved altogether as you have jars you said. I checked Appodeal and few errors while integrating it and came across this [new accepted answer](https://stackoverflow.com/a/41838973/6097322), if that could resolve your issue. – Dhara Bhavsar Feb 14 '18 at 20:26
  • 1
    the problem was solved when I deleted recyler view lib from libs. thank you! – mtrfnv Feb 15 '18 at 17:37