【问题标题】:java.util.zip.ZipException: duplicate entry: android/support/v4/view/ViewPager$MyAccessibilityDelegate.classjava.util.zip.ZipException:重复条目:android/support/v4/view/ViewPager$MyAccessibilityDelegate.class
【发布时间】:2017-09-06 03:07:50
【问题描述】:

我是 Android 编程新手,请帮助我。

我在编译我的应用程序时遇到了这样的错误:

错误:任务 ':app:transformClassesWithJarMergingForDebug' 执行失败。

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:android/support/v4/view/ViewPager$MyAccessibilityDelegate.class

这是我的 gradle 文件:

    apply plugin: 'com.android.application'


    android {
        compileSdkVersion 17
        buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.ecs.google.maps.v2.actionbarsherlock"
        minSdkVersion 9
        targetSdkVersion 17
        // Enabling multidex support.
        multiDexEnabled true
    }

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

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

}

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

dependencies {
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile ('com.android.support:gridlayout-v7:+') {
        exclude module: 'support-v4'
    }

    compile 'com.astuetz:pagerslidingtabstrip:1.0.0'
    compile ('com.google.maps.android:android-maps-utils:0.3+') {
        exclude module: 'support-v4'
    }

    compile 'com.google.code.gson:gson:2.1'
    compile ('com.google.android.gms:play-services-maps:8.4.0') {
        exclude module: 'support-v4'
    }



    compile files('libs/google-http-client-1.15.0-rc.jar')
    compile files('libs/google-http-client-android-1.15.0-rc.jar')
    compile files('libs/google-http-client-jackson2-1.15.0-rc.jar')
    compile files('libs/httpclient-4.0.1.jar')
    compile files('libs/httpcore-4.0.1.jar')
    compile files('libs/jackson-core-2.1.3.jar')
    compile files('libs/jackson-core-asl-1.9.11.jar')


}

我已经删除了我的 lib 文件夹中所有重复的 support-v4 文件。

您能说出我的代码有什么问题吗?感谢您的帮助。

【问题讨论】:

    标签: android duplicates


    【解决方案1】:

    以下脚本并不总是排除 support-v4

    compile ('some-module') {
        exclude module: 'support-v4'
    }
    

    因为模块名称可能不同。 因此,您需要先找出模块名称(ARTIFACT_ID)才能排除正确的。

    就我而言,添加 RecyclerView 作为我的项目依赖项会导致以下错误。

    重复条目: android/support/v4/view/ViewPager$MyAccessibilityDelegate.class

    重复条目: android/support/v4/hardware/display/DisplayManagerCompat.class

    我发现了使用 gradle task androidDependencies 的模块。

    执行此任务将显示依赖关系树(参考下图)。

    然后删除不需要的或重复的模块。

    compile ('com.android.support:recyclerview-v7:+') {
       exclude module: "support-core-ui"
       exclude module: "support-compat"
    }
    

    【讨论】:

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