重复的 zip 条目 [classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class]
Duplicate zip entry [classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class]
我有以下依赖并得到 CoordinatorLayout$Behavior
重复条目。我搜索了这么多但没有找到任何解决方案。
我得到
Caused by: java.io.IOException: Duplicate zip entry [classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class]
at proguard.io.JarWriter.getOutputStream(JarWriter.java:138)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:92)
at proguard.io.ClassRewriter.read(ClassRewriter.java:68)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.JarReader.read(JarReader.java:65)
at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65)
at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53)
at proguard.InputReader.readInput(InputReader.java:184)
... 50 more
核心 UI 从哪里来?我认为这会产生问题。谁能知道我需要在哪里排除其中一个库?
我已经探索了我所有的库并有以下场景。
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// compile('com.mikepenz:materialdrawer:5.8.0@aar') {
// transitive = true
// }
compile 'com.android.support:multidex:1.0.2'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:support-v4:27.0.0'
compile 'com.android.support:recyclerview-v7:27.0.0'
compile 'com.android.support:design:27.0.0'
compile 'com.android.support:cardview-v7:27.0.0'
compile 'com.google.android.gms:play-services-gcm:11.8.0'
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.pnikosis:materialish-progress:1.7'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.github.rey5137:material:1.2.4'
compile 'org.apache.commons:commons-lang3:3.6'
compile 'com.afollestad.material-dialogs:core:0.9.5.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
compile 'com.github.travijuu:numberpicker:1.0.7'
compile 'com.github.carlosmuvi:SegmentedProgressBar:0.6.0'
compile 'com.nex3z:notification-badge:0.3.0'
compile 'com.bogdwellers:pinchtozoom:0.1'
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
compile 'com.aurelhubert:ahbottomnavigation:2.1.0'
testCompile 'junit:junit:4.12'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile files('libs/PGSDK_V2.1.jar')
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.race604.waveloading:library:1.1.1'
compile 'com.karumi:dexter:4.2.0'
compile 'com.msg91.sendotp.library:library:3.1'
}
我就是这么做的。现在可以使用了
解决方案 1
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:support-v4:27.1.0'
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
compile 'com.android.support:cardview-v7:27.1.0'
解决方案 2(新)
将您的代码迁移到 AndroidX
除了使用 Project
视图 -> External Libraries
,我使用 gradle
命令将依赖项输出到一个 txt 文件中以供搜索。在 Mac 上使用 ./gradlew
,在 Window 上使用 gradlew.bat
。
$ ./gradlew -q :app:dependencies > dependencies.txt
例如,在 dependencies.txt
中,使用 "Find" 并键入 "design",然后查看所有突出显示的库及其版本号。从一些 SO post 中,他们建议排除重复的依赖项。如果一个依赖项被另一个依赖项包含(例如,com.android.support:cardview-v7
被 com.firebaseui:firebase-ui-auth
包含),我们可以从 app/build.gradle.[=24= 中省略该依赖项]
我通过从 gradle:
中删除这些依赖项来修复我的项目
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-vector-drawable:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
我保留这个(并从 27.0.2 升级到 27.1.0):
implementation 'com.android.support:design:27.1.0'
将排除添加到以下依赖项:
implementation 'com.firebaseui:firebase-ui-auth:3.1.2', {
exclude group: 'android.arch.lifecycle', module: 'extensions'
exclude group: 'com.android.support', module: 'design'
}
implementation 'com.romandanylyk:pageindicatorview:1.0.0', {
exclude group: 'com.android.support', module: 'support-core-ui'
}
我在 add/remove 依赖项之后遇到了生命周期问题。另一个 SO post 建议包含两个不同版本的库。因此,我在第 1 步中更新了输出文件并检查:
+--- 'com.google.firebase:firebase-core:11.8.0'
| +--- 'android.arch.lifecycle:runtime:1.1.0'
+--- 'com.firebaseui:firebase-ui-auth:3.1.2'
| +--- 'android.arch.lifecycle:extensions:1.0.0'
排除android.arch.lifecycle:extensions
即可解决编译问题
运行 查看应用依赖项
gradlew -q :app:dependencies > dependencies.txt
它会输出一棵大树,其中:
- (*) 用于指示特定依赖项在树的其他地方描述
- ->(箭头)用于指出版本冲突中胜的依赖。默认情况下,gradle 选择最新版本。
输出:
+--- com.android.support:design:26.1.0
| +--- com.android.support:support-v4:26.1.0 (*)
| +--- com.android.support:appcompat-v7:26.1.0 -> 27.1.1 (*)
| +--- com.android.support:recyclerview-v7:26.1.0 (*)
| \--- com.android.support:transition:26.1.0
| +--- com.android.support:support-annotations:26.1.0 -> 27.1.1
| \--- com.android.support:support-v4:26.1.0 (*)
在我的例子中,我发现 com.android.support:design:26.1.0
取决于 com.android.support:appcompat-v7:26.1.0 -> 27.1.1 (*)
,它解析为 27.1.1 而不是 26.1.0
解决方案
通过在 gradle compile ("com.android.support:appcompat-v7:26.1.0") { force = true }
中声明强制版本 26.1.0
参考文献
- Gradle: how to display where a dependency conflict arises
- Understanding and dominating gradle dependencies
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support:support-v4:27.0.0'
implementation 'com.android.support:design:27.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.intuit.sdp:sdp-android:1.0.4'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.android.support:cardview-v7:27.0.0'
implementation 'com.android.support:recyclerview-v7:27.0.0'
我有以下依赖并得到 CoordinatorLayout$Behavior
重复条目。我搜索了这么多但没有找到任何解决方案。
我得到
Caused by: java.io.IOException: Duplicate zip entry [classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class]
at proguard.io.JarWriter.getOutputStream(JarWriter.java:138)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:92)
at proguard.io.ClassRewriter.read(ClassRewriter.java:68)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.JarReader.read(JarReader.java:65)
at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65)
at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53)
at proguard.InputReader.readInput(InputReader.java:184)
... 50 more
核心 UI 从哪里来?我认为这会产生问题。谁能知道我需要在哪里排除其中一个库?
我已经探索了我所有的库并有以下场景。
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// compile('com.mikepenz:materialdrawer:5.8.0@aar') {
// transitive = true
// }
compile 'com.android.support:multidex:1.0.2'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:support-v4:27.0.0'
compile 'com.android.support:recyclerview-v7:27.0.0'
compile 'com.android.support:design:27.0.0'
compile 'com.android.support:cardview-v7:27.0.0'
compile 'com.google.android.gms:play-services-gcm:11.8.0'
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.pnikosis:materialish-progress:1.7'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.github.rey5137:material:1.2.4'
compile 'org.apache.commons:commons-lang3:3.6'
compile 'com.afollestad.material-dialogs:core:0.9.5.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
compile 'com.github.travijuu:numberpicker:1.0.7'
compile 'com.github.carlosmuvi:SegmentedProgressBar:0.6.0'
compile 'com.nex3z:notification-badge:0.3.0'
compile 'com.bogdwellers:pinchtozoom:0.1'
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
compile 'com.aurelhubert:ahbottomnavigation:2.1.0'
testCompile 'junit:junit:4.12'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile files('libs/PGSDK_V2.1.jar')
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.race604.waveloading:library:1.1.1'
compile 'com.karumi:dexter:4.2.0'
compile 'com.msg91.sendotp.library:library:3.1'
}
我就是这么做的。现在可以使用了
解决方案 1
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:support-v4:27.1.0'
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
compile 'com.android.support:cardview-v7:27.1.0'
解决方案 2(新)
将您的代码迁移到 AndroidX
除了使用 Project
视图 -> External Libraries
,我使用 gradle
命令将依赖项输出到一个 txt 文件中以供搜索。在 Mac 上使用 ./gradlew
,在 Window 上使用 gradlew.bat
。
$ ./gradlew -q :app:dependencies > dependencies.txt
例如,在 dependencies.txt
中,使用 "Find" 并键入 "design",然后查看所有突出显示的库及其版本号。从一些 SO post 中,他们建议排除重复的依赖项。如果一个依赖项被另一个依赖项包含(例如,com.android.support:cardview-v7
被 com.firebaseui:firebase-ui-auth
包含),我们可以从 app/build.gradle.[=24= 中省略该依赖项]
我通过从 gradle:
中删除这些依赖项来修复我的项目implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-vector-drawable:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
我保留这个(并从 27.0.2 升级到 27.1.0):
implementation 'com.android.support:design:27.1.0'
将排除添加到以下依赖项:
implementation 'com.firebaseui:firebase-ui-auth:3.1.2', {
exclude group: 'android.arch.lifecycle', module: 'extensions'
exclude group: 'com.android.support', module: 'design'
}
implementation 'com.romandanylyk:pageindicatorview:1.0.0', {
exclude group: 'com.android.support', module: 'support-core-ui'
}
我在 add/remove 依赖项之后遇到了生命周期问题。另一个 SO post 建议包含两个不同版本的库。因此,我在第 1 步中更新了输出文件并检查:
+--- 'com.google.firebase:firebase-core:11.8.0'
| +--- 'android.arch.lifecycle:runtime:1.1.0'
+--- 'com.firebaseui:firebase-ui-auth:3.1.2'
| +--- 'android.arch.lifecycle:extensions:1.0.0'
排除android.arch.lifecycle:extensions
即可解决编译问题
运行 查看应用依赖项
gradlew -q :app:dependencies > dependencies.txt
它会输出一棵大树,其中:
- (*) 用于指示特定依赖项在树的其他地方描述
- ->(箭头)用于指出版本冲突中胜的依赖。默认情况下,gradle 选择最新版本。
输出:
+--- com.android.support:design:26.1.0
| +--- com.android.support:support-v4:26.1.0 (*)
| +--- com.android.support:appcompat-v7:26.1.0 -> 27.1.1 (*)
| +--- com.android.support:recyclerview-v7:26.1.0 (*)
| \--- com.android.support:transition:26.1.0
| +--- com.android.support:support-annotations:26.1.0 -> 27.1.1
| \--- com.android.support:support-v4:26.1.0 (*)
在我的例子中,我发现 com.android.support:design:26.1.0
取决于 com.android.support:appcompat-v7:26.1.0 -> 27.1.1 (*)
,它解析为 27.1.1 而不是 26.1.0
解决方案
通过在 gradle compile ("com.android.support:appcompat-v7:26.1.0") { force = true }
参考文献
- Gradle: how to display where a dependency conflict arises
- Understanding and dominating gradle dependencies
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support:support-v4:27.0.0'
implementation 'com.android.support:design:27.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.intuit.sdp:sdp-android:1.0.4'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.android.support:cardview-v7:27.0.0'
implementation 'com.android.support:recyclerview-v7:27.0.0'