Error:Execution failed for task ':app:transfor

2018-12-31 16:49发布

Good day. After updating google repository in AndroidStudio, I have an issue

> Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry:
> android/support/v7/cardview/BuildConfig.class

I'm trying to exclude group android.support from play-services, it did not help. When I started my project on another PC I have:

> Error:Execution failed for task  ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry:
> android/support/annotation/AnimRes.class

my build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "ru.alexeyk.myevents"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 16
        versionName "1.121"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.github.nkzawa:socket.io-client:0.4.2') {
        exclude group: 'org.json', module: 'json'
    }
    compile files('libs/sentry-1.1.4.jar')
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:support-annotations:23.1.0'
    compile 'com.android.support:design:23.1.0'
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.android.support:cardview-v7:23.1.0'
    compile 'com.android.support:recyclerview-v7:23.1.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
    compile 'com.github.machinarius:preferencefragment:0.1.2'
    compile 'com.edmodo:cropper:1.0.1'
    compile 'com.makeramen:roundedimageview:2.1.1'
    compile 'org.ocpsoft.prettytime:prettytime:4.0.0.Final'
    compile 'com.yandex.android:mobmetricalib:2.00@aar'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.google.android.gms:play-services-ads:8.1.0'
    compile 'com.google.android.gms:play-services-analytics:8.1.0'
    compile 'com.google.android.gms:play-services-identity:8.1.0'
    compile 'com.google.android.gms:play-services-gcm:8.1.0'
}

11条回答
千与千寻千般痛.
2楼-- · 2018-12-31 17:11

I resolve this is by changing the version no of recyleview to recyclerview-v7:24.2.1. Please check your dependencies and use the proper version number.

查看更多
呛了眼睛熬了心
3楼-- · 2018-12-31 17:15

Use project root in terminal like this:-/Users/rajnish/Desktop/RankProjects/ProjectCloud

After that enter this command ./gradlew clean

It will work.

查看更多
时光乱了年华
4楼-- · 2018-12-31 17:16

In terminal execute in root project folder:

./gradlew clean

It helped me.

查看更多
步步皆殇っ
5楼-- · 2018-12-31 17:16

I resolved the issue by double checking the "libs" directory and removing redundant jars, even though those jars were not manually added in the dependencies.

查看更多
何处买醉
6楼-- · 2018-12-31 17:18

I got this error because I did not have the correct line in my build.gradle. I am using the org.apache.http.legacy.jar library, which requires this:

android{
   useLibrary 'org.apache.http.legacy'

   ...
}

So check that you have everything in your gradle file that is required.

查看更多
只若初见
7楼-- · 2018-12-31 17:22

All the above not working for me.. Because I am using Facebook Ad dependency..

Incase If anybody using this dependency compile 'com.facebook.android:audience-network-sdk:4.16.0'

Try this code instead of above

compile ('com.facebook.android:audience-network-sdk:4.16.0'){
exclude group: 'com.google.android.gms'
}
查看更多
登录 后发表回答