0

当我解决最常见的问题时,我遇到了这个问题错误:任务':app:transformClassesWithJarMergingForDebug'的执行失败。

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:android/support/v4/graphics/BitmapCompat.class

我的毕业班::

 apply plugin: 'com.android.application'

android {
    //compileSdkVersion 25
    //buildToolsVersion "25.0.0"
    compileSdkVersion 21
    buildToolsVersion '24.0.3'
    defaultConfig {
        applicationId "com.scrollcoupons.com.kada"
      //  minSdkVersion 19
      //  targetSdkVersion 25
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true //important
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
  //  compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile 'com.android.support:support-v4:21.0.3'

   compile 'com.android.support:appcompat-v7:21.0.3'

   compile 'com.github.Yalantis:GuillotineMenu-Android:1.2'
    //compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.jakewharton:butterknife:8.8.1'
    //compile 'com.android.support:design:25.3.1'
   // testCompile 'junit:junit:4.12'
    //annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    //add external library
    compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0@aar'


}
4

3 回答 3

1

你应该排除重复的库

   android {
    //compileSdkVersion 25
    //buildToolsVersion "25.0.0"
    compileSdkVersion 21
    buildToolsVersion '24.0.3'
    defaultConfig {
        applicationId "com.scrollcoupons.com.kada"
      //  minSdkVersion 19
      //  targetSdkVersion 25
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true //important
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

 ----->  configurations {
            all*.exclude group: 'com.android.support', module: 'support-v4'
            all*.exclude group: 'com.android.support', module: 'support-annotations'


    }
}
于 2017-09-08T20:33:03.217 回答
0

第 1 步:在这种情况下,主要提示是 android/support/v4/graphics/BitmapCompat.class

第 2 步:搜索类,在您的情况下是“BitmapCompat.class”(在 AndroidStudio 中,只需在 Windows 上按 Ctrl+N 或在 Mac 上按 CMD-O)

第 3 步:查看哪个 jar 包含它 - Android Studio 将在弹出窗口中写入它。

第 4 步:将其从所有构建中排除,

例如:

com.android.support:support-v4:_____

compile('your_conflicted_dependency')
{
     exclude module: 'support-v4'
}
于 2017-09-08T21:00:46.367 回答
0

将代码添加到build.gradle

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
    all*.exclude group: 'com.android.support', module: 'support-annotations' 
}
于 2018-01-13T05:57:04.207 回答