Error: java.util.zip.ZipException: duplicate entry

对着背影说爱祢 提交于 2019-11-26 17:53:29
compile 'com.android.support:support-v4:22.1.1'
compile ('com.android.support:appcompat-v7:22.1.1') {
    exclude module: 'support-v4'
}
compile ('com.facebook.android:facebook-android-sdk:4.2.0') {
    exclude module: 'support-v4'
}
compile ('com.github.navasmdc:PhoneTutorial:1.+@aar') {
    exclude module: 'support-v4'
}

I use this to replace all support libraries versions with the latest one that i use in gradle file:

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "26.0.1"
            }
        }
    }
}

Try using this versions in build.gradle file.

compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'

Your Error:

java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelperKitkat$2$1.class

Step 1: In this case main hint is android/support/v4/print/PrintHelperKitkat$2$1.class

Step 2: Searching for the class, in your case the "PrintHelperKitkat.class" (in AndroidStudio just hit Ctrl+N on Windows or CMD-O on Mac)

Step 3: See which jar contains it - Android Studio will write it in the popup.

Step 4: Exclude it from all builds,

for example:

com.android.support:support-v4:_____

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

In my case my one dependency also included in my another AAR. So I deleted that dependency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!