java.util.zip.ZipException : packageAllDebugClassesForMultiDex 중 중복 항목


118

이 오류가 무엇을 의미하는지 잘 모르겠습니다.

Execution failed for task ':excelSior:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/util/TimeUtils.class

현재 android-support-v4.jar내 라이브러리에 사용 하고 있습니다.

dependencies {
    compile project(':addThisSDK')
    compile project(':centeredContentButton')
    compile project(':googleplayservices_lib')
    compile files('libs/adxtag2.4.6.jar')
    compile files('libs/android-support-v4.jar')
    compile files('libs/aws-android-sdk-1.7.1.1-debug.jar')
    compile files('libs/commons-lang-2.6.jar')
    compile files('libs/crittercism_v4_4_0_sdkonly.jar')
    compile files('libs/dd-plist.jar')
    compile files('libs/FiksuAndroidSDK_4.1.1.jar')
    compile files('libs/iqengines-sdk-barcode.jar')
    compile files('libs/irEventTracker-1.2.jar')
    compile files('libs/jolt-core-0.0.7.jar')
    compile files('libs/json-utils-0.0.7.jar')
    compile files('libs/jsoup-1.7.2.jar')
    compile files('libs/kooaba-api-v4-java.jar')
    compile 'com.android.support:multidex:1.0.0'
}

Gradle 동기화 중에 오류가 표시되지 않습니다. 응용 프로그램을 실행하려고 할 때

무엇이 문제일까요?


1
오류는 다른 jar 종속성에 동일한 클래스가있을 때 발생합니다. gradle 및 jar 종속성으로 지원 jar를 모두 추가하지 않았는지 확인하십시오. 질문에 완전한 종속성 폐쇄를 포함하십시오.
— pyus13

@ pyus13 감사합니다. 질문을 업데이트했습니다. 이것은 내 모든 의존성 목록
— bman

1
프로젝트에 3 개의 모듈 종속성이 있으므로 이들 중 하나만 종속성으로 support-v4를 갖도록하십시오.
— pyus13 2014

내 대답을 참조하십시오 : stackoverflow.com/questions/28168063/…
— Tomer

오류 : ': Mulugu Astro : transformClassesWithJarMergingForDebug'작업에 대한 실행이 실패했습니다. > com.android.build.api.transform.TransformException : java.util.zip.ZipException : 중복 된 항목 : 안드로이드 / 지원 / V4 /보기 / ViewPager $ MyAccessibilityDelegate.class
— Harsha에

답변:


64

v4 라이브러리를 삽입하고 라이브러리를 컴파일했는지 확인해야합니까? 앱이나 의존성 프로그램에서 라이브러리를 반복해서는 안됩니다.

V4가 하나만 남도록 반복 라이브러리를 삭제하십시오.

앱 dir build.gradle파일에 다음 명령을 추가하십시오.

android{


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

}

그것은 나를 위해 작동합니다! 시도해 볼 수 있습니다!


19
이 조각을 추가 한 후 v4 지원을받을 수 없습니다.
— Nisarg 2016

@Nisarg도 나에게 발생합니다.
— CJ_COIMBRA

@Nisarg 당신은 프로그램을 다시 컴파일하는 gradle을 사용할 수 있습니다.
— GeekHades

당신은 내가 어떻게 다시 컴파일하는 데 도움을 기쁘게 @NisargCan, 나도 당신, 조각과 같은 문제를 가지고 taskstackbuilder가 해결 중지
— Gaurav 아 로라를

82

지금까지이 문제를 해결했지만 답이없는 상태로 유지되지 않도록 다음을 추가해보세요 build.gradle.

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

4
구성 라인을 추가했지만 여전히 Error:Execution failed for task ':Analyst:packageAllDebugClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry: com/android/vending/billing/IInAppBillingService$Stub$Proxy.class표시됩니다.
— biswajitGhosh

2
문제를 어떻게 해결 했습니까?
— Arslan Anwar

9
올바른 솔루션이 있습니까? 같은 문제가 발생합니다. java.util.zip.ZipException : 중복 항목 : com / google / gson / annotations / Expose.class
— RamBabu Pudari

2
오류 : (5, 30) 오류 : 패키지 android.support.v4.app 당신의 대답 추가 한 후이 오류가 존재하지 않습니다
— ANKIT Thakkar

1
이것이 어디로 가야하는지, 나는 gradle을 처음 사용하고 현재 프로젝트에 5 개의 build.gradle 파일이 configurations있으며 그중 어느 것도 파일에 포함 되어 있지 않으며 어디에 두 었는지 중요하지 않은 것 같습니다. 할 수없는 것과 같은 오류가 발생합니다. 해결 기호는 '제외'또는 기호 '모든'해결할 수없는
— JStephen

25

이전 이클립스 프로젝트를 다시 가져올 때도 이런 종류의 문제가 발생했습니다. 프로젝트에서 jar 파일로 오래된 종속성이 발생했습니다.

그냥 제거

컴파일 fileTree (dir : 'libs', include : '* .jar')

gradle 파일에서

gradle 파일에 종속성을 추가하십시오.

그것은 나를 위해 작동합니다 ..


이 오류는 이전 이클립스 프로젝트를 가져올 때 발생했습니다. 실제로 일부 참조 라이브러리를 제거하고 gradle 파일에 동일한 종속성을 추가했습니다.
— Paraneetharan Saravanaperumal

1
나를 위해 일했습니다 (이전 이클립스 구성에서도 가져 오기). 그 후 청소 및 재건이 필요했습니다.
— Paco Abato

17
왜 내가 Sauron이라는 이름을 믿어야합니까?
— matthias_b_nz

이 특정 오류를 중지했지만 다른 오류가 발생했습니다. 때로는 이러한 종속성이 필요합니다. 이상하게 들릴지 모르지만 이번에는 Sauron이 옳았습니다.
— SMBiggs

1
종속성을 하나씩 명시 적으로 추가 .jar하면 두 번 포함 하는 중복 라이브러리를 발견 할 수 있습니다. 절대 사용하지 마십시오 compile fileTree(...). 너무 많은 명백한 오류를 숨 깁니다.
— Joshua Pinter

13

제 경우에는 설정 후 언급 된 "중복 입력"오류가 발생했습니다.multiDexEnable=true build.gradle에서 했습니다.

오류를 완전히 해결하려면 먼저 64K 이상의 방법으로 앱 구성을 살펴보십시오. 앱 구성 (특히 "Gradle로 Multidex 용 앱 구성")을 살펴보십시오.

또한 Android Studio에서 ctrl + n을 사용하여 "중복 항목"오류를 일으키는 클래스 발생을 검색하십시오. 중복을 포함하는 모듈 및 종속성을 확인하고 빌드에서 제외합니다. 예 :

compile ('org.roboguice:roboguice:2.0') {
    exclude module: 'support-v4'
}

작동 할 때까지 여러 모듈 레이블을 시도해야했습니다. "support-v4"를 제외하면 "java.util.zip.ZipException : duplicate entry : android / support / v4 / *"와 관련된 문제가 해결됩니다.


9

내 이해는 동일한 API에 대한 중복 참조가 있다는 것입니다 (아마도 다른 버전 번호). 명령 줄에서 빌드 할 때 디버그하기가 합리적으로 쉬워야합니다.

./gradlew yourBuildVariantName --debug명령 줄에서 시도하십시오 .

문제가되는 항목이 첫 번째 실패입니다. 예는 다음과 같습니다.

14:32:29.171 [INFO] [org.gradle.api.Task] INPUT: /Users/mydir/Documents/androidApp/BaseApp/build/intermediates/exploded-aar/theOffendingAAR/libs/google-play-services.jar

14:32:29.171 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':BaseApp:packageAllyourBuildVariantNameClassesForMultiDex'

14:32:29.172 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :BaseApp:packageAllyourBuildVariantNameClassesForMultiDex FAILED'

위의 경우 내 libs 디렉토리 (theOffendingAAR)에 포함 된 aar 파일에는 Google Play 서비스 jar (예, 예, 알고 있습니다.) 파일이 포함되었으며 BaseApp 빌드 파일은 위치 서비스를 사용했습니다.

compile 'com.google.android.gms:play-services-location:6.5.87'

빌드 파일에서 문제가되는 항목을 안전하게 제거하고 정리하고 다시 빌드 할 수 있습니다 (필요한 경우 반복).


1
그렇다면 문제가되는 라이브러리가 필요하면 어떻게해야합니까?
— Janusz

1
이것은 제가 문제가되는 라이브러리를 추적하는 데 도움이되었습니다. :)
— speedynomads

1
잘못된 라이브러리를 모듈을 제거하는이 나던 help..on는 컴파일에 실패
— Utsav 굽타에게

9

종속성 버전을 확인하십시오. 호환되는 버전이 특히 com.google 패키지에주의를 기울여야하며 다음과 같은 동일한 버전이 있어야합니다.

compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'

둘 다 8.3.0이며 다른 버전을 컴파일하면 해당 예외가 발생합니다.


감사합니다. 완벽하게 작동합니다. 세 가지 Google Play 서비스가 있습니다. compile 'com.google.android.gms : play-services-analytics : 8.4.0'compile 'com.google.android.gms : play-services-ads : 8.3 .0 '
— compile'com.google.android.gms

5

종속성에서 Jar 파일을 간단히 제거하십시오. gardle.project를 v7로하고 프로젝트를 실행하십시오.


그것은 나를 위해 작동합니다. "build.gradle (Module : app)"에서 "compile files ( 'libs / android-support-v13.jar')"양식 "dependencies"를 제거하십시오. 참고로 프로젝트 양식을 Android Studio로 가져온 후이 오류가 발생합니다.
— rafaellorey

5

Expose.class 오류 즉

java.util.zip.ZipException : 중복 항목 : com / google / gson / annotations / Expose.class

아래 코드를 사용하십시오

configurations {
    all*.exclude  module: 'gson'
}

11
OP는에 대해 아무 말도하지 않았다 gson.
— IgorGanapolsky

3

lib가 v4 지원에 의존하는지 확인하고 제외하십시오.

코드 입력 build.gradle은 다음과 같습니다.

androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
    // http://stackoverflow.com/a/30931887/5210
    exclude group: 'com.android.support', module: 'appcompat'
    exclude group: 'com.android.support', module: 'support-v4'
    exclude module: 'recyclerview-v7'
}

내 상황에서 lib 'espresso'에는 support-v4라는 항아리가 있고 내 프로젝트 'app'에는 동일한 support-v4가 있으며 espresso를 가져올 때 support-v4를 제외합니다.

추신 : 그것은 compile project작동하지 않는 것 같습니다exclude


1

이는 라이브러리를 추가하고 모듈에 대한 종속성을 두 번 이상 부여했기 때문입니다.

제 경우에는 라이브러리를 모듈과 gradle 종속성으로 추가했습니다.

라이브러리를 추가하는 하나의 소스를 제거하면 (gradle 종속성 제거) 문제가 해결되었습니다.


또는 libs dir에서 jar를 제거하고 gradle 종속성을 유지하여이 문제를 해결했습니다.
— droideckar

예! 단일 소스를 제거하면 문제가 발생합니다. Gradle 의존성을 유지하는 것이 좋습니다.
— 라훌 Rastogi

0

오류 : ': app : transformClassesWithJarMergingForDebug'작업에 대한 실행 실패 com.android.build.api.transform.TransformException java.util.zip.ZipException 중복 항목 com / google / gson / annotations / Expose.class

내가 한 일은 다음과 같습니다.

1) gson-2.5.jar 파일을 삭제합니다. 2) 구성 {all * .exclude 모듈 : 'gson-2.5'}


질문 GSON에 대해 아니었다
— OneCricketeer

0

libs에서 jar를 수동으로 복사하고 gradle 파일의 종속성을 언급했기 때문에이 문제에 직면했습니다. 또한 동일한 jar 파일이 libs와 같은 다른 폴더 또는 프로젝트 폴더에 복사되었는지 여부를 프로젝트 구조에서 확인합니다.


0

Android SDK를 업그레이드 한 후에도 동일한 문제가 발생했습니다. 에서 응용 프로그램을 실행할 수 있었지만 다음으로 buildToolsVersion '23.0.1'변경했을 때 동일한 오류가 발생했습니다.buildToolsVersion '24.0.3'

Java 버전을 1.7에서 1.8로 업데이트하여 문제를 해결했습니다. compileSdkVersion 24


0

이 문제는 하루 종일 비용이 듭니다. 마침내 firebase-ui 라이브러리 버전을 2.0.0에서 1.2.0으로 다운 그레이드하고 프로젝트 수준 build.gradle 파일에 다음 코드를 추가했습니다.

allprojects {
    repositories {
        jcenter()

        // Add the following code to your project level build.gradle
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
}

1
중포 기지 UI 버전은 중포 기지의 버전에 실제로 컴파일 의존
— OneCricketeer

0

나는 또한 'com.android.support:appcompat-v7:24.0.0-alpha1'을 컴파일했기 때문에 문제가 있지만 recyclerview liberary compile 'com.android.support:recyclerview-v7:24.0.2'를 추가했습니다 .. 나는 (24.0.0의 24.0.2 intead)와 같은 compat과 동일한 버전을 변경했습니다.

나는 대답을 얻었다. 누군가에게 도움이 될지도 모른다.


0

필자의 경우 build.gradle에서 multiDexEnable = true를 설정 한 후 언급 된 "중복 항목"오류가 발생했습니다.

내가 얻은 정확한 오류는 다음과 같습니다.

Error:Execution failed for task 
':android:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: 
java.util.zip.ZipException: duplicate entry: 
com/google/android/gms/internal/zzqx.class

그래서 먼저 Android Studio에서 ctrl + n을 사용하여 "중복 항목"오류를 일으키는 클래스를 검색하고 com / google / android / gms / internal / zzqx.class를 검색 한 다음 하나의 버전으로 gms 클래스에 대해 2 개의 항목을 표시했습니다. 8.4.0 및 1 버전 11.6.0.

그것을 수정하기 위해 11.6.0을 사용하도록 만들었고 수정 된 예였습니다.

일찍이

    compile "com.google.android.gms:play-services-games:11.6.0"
    compile "com.google.android.gms:play-services-auth:8.4.0"
    compile "com.google.android.gms:play-services-ads:11.6.0"

후

    compile "com.google.android.gms:play-services-games:11.6.0"
    compile "com.google.android.gms:play-services-auth:11.6.0"
    compile "com.google.android.gms:play-services-ads:11.6.0"

재 구축 고정.


0

제 경우에는 정확한 오류가 아래에있었습니다.

': android : transformClassesWithJarMergingForDebug'입니다.

com.android.build.api.transform.TransformException : java.util.zip.ZipException : 중복 항목 : com / google / android / gms / internal / zzqx.class

하나의 모듈 gradle 파일에서 다른 버전의 Google API를 사용했습니다.

if (!project.hasProperty('gms_library_version')) {
        ext.gms_library_version = '8.6.0'
   }

그러나 다른 모듈 버전 11.6.0에서는 아래와 같이

   compile "com.google.android.gms:play-services-ads:11.6.0"
    compile "com.google.android.gms:play-services-games:11.6.0"
    compile "com.google.android.gms:play-services-auth:11.6.0"

그러나 이것을 찾기 위해 나는 안드로이드 스튜디오에서 ctrl + n을하고 클래스 이름 zzqx.class를 입력 한 다음이 클래스에 대해 2 개의 jar 파일을 가져 오는 것을 표시 한 다음 어딘가에서 버전 8.6.0을 사용하고 있음을 이해했습니다. 8.6.0을 11.6.0으로 변경하고 프로젝트를 다시 빌드 할 때 문제가 해결되었습니다.

도움이 되었기를 바랍니다 .

여기에 대한 자세한 내용은 https://www.versionpb.com/tutorials/step-step-tutorials-libgdx-basic-setup-libgdx/implementing-google-play-services-leaderboards-in-libgdx/


0

나에게 실수로 추가했을 때 비슷한 일이 일어났습니다.

apply plugin: 'kotlin-android'

내 안드로이드 라이브러리 모듈에. 줄을 제거하면 문제가 해결됩니다.


0

위의 모든 솔루션을 시도했지만 나를 위해 일하지 않았습니다. goto 프로젝트 구조> 앱으로 라이브러리 업데이트를 시도했습니다. 그리고 그것은 나를 위해 작동합니다! 이 답변이 누군가에게 도움이 되었기를 바랍니다.


-1

이 시도:

android {
configurations {
        all*.exclude  module: 'PhotoView'  //去除重复依赖库
    }
}

이 질문은 지원 V4 라이브러리,하지에서 PhotoView에 관한 것입니다
— OneCricketeer

-1

android / support / v4 / util / TimeUtils.class를 지우십시오.


예수 그리스도 아니오
— sfratini
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.