【问题标题】:Error:Execution failed for task : java.util.zip.ZipException: duplicate entry: android/support/v4/graphics/BitmapCompat.class错误:任务执行失败:java.util.zip.ZipException:重复条目:android/support/v4/graphics/BitmapCompat.class
【发布时间】:2018-01-13 15:31:57
【问题描述】:

当我解决最常见的问题时,我遇到了这个问题 错误:任务 ':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'


}

【问题讨论】:

  • 当与黄油刀依赖和“support-v4:21.0.3”库结合使用时会导致此问题,因此我选择删除黄油刀,没关系

标签: java android exception compiler-errors android-gradle-2.0


【解决方案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'


    }
}

【讨论】:

  • 在您的应用程序 gradle 文件中。只需将配置放入 android {}
  • 它为我产生了很多错误,因为我在 support-v4 下使用 ActionBarActivity
  • 为什么不使用 AppCompactActivity 来代替?
  • 因为我使用的是 PullZoomView 库,使用 AppCompactActivity 时发生冲突 ..
  • 尝试从第三方库中排除 v4 库...因为您已经在使用 compile 'com.android.support:support-v4:21.0.3'
【解决方案2】:

第 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'
}

【讨论】:

    【解决方案3】:

    build.gradle中添加代码

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-18
      • 1970-01-01
      • 1970-01-01
      • 2015-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多