首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >回收视图-v7:24.2.0导致ZipException

回收视图-v7:24.2.0导致ZipException
EN

Stack Overflow用户
提问于 2016-09-08 15:47:29
回答 2查看 353关注 0票数 0

我正在尝试使用回收视图中引入的新的DiffUtil类--v7:24.2.0。

但是,我发现更新build.gradle中的依赖项使我无法再运行我的应用程序。

下面是将构建的当前依赖项列表

代码语言:javascript
复制
dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')

  compile 'com.android.support:recyclerview-v7:24.1.1'

  compile 'com.android.support:multidex:1.0.1'
  compile 'com.android.support:cardview-v7:24.2.0'
  androidTestCompile 'com.android.support:support-annotations:24.2.0'
  androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
  androidTestCompile 'com.android.support.test:runner:0.5'
  compile 'com.github.siyamed:android-shape-imageview:0.9.3@aar'
  compile 'com.neovisionaries:nv-websocket-client:1.12'
  compile 'com.nightonke:jellytogglebutton:1.0.2'
  compile 'com.squareup.okhttp3:okhttp:3.4.0-RC1'
  compile 'com.squareup.picasso:picasso:2.5.2'
  compile 'de.greenrobot:eventbus:2.4.0'
  compile 'de.hdodenhof:circleimageview:2.0.0'
  compile('com.github.ozodrukh:CircularReveal:1.3.1@aar') {
    transitive = true;
  }
  compile 'com.jakewharton:butterknife:8.1.0'
  apt 'com.jakewharton:butterknife-compiler:8.1.0'
  compile 'io.reactivex:rxandroid:1.2.1'
  compile 'io.reactivex:rxjava:1.1.6'
  compile "com.github.fge:json-patch:1.9"
  apt 'com.squareup:javapoet:1.7.0'
  apt 'com.google.dagger:dagger-compiler:2.2'
  compile 'com.google.dagger:dagger:2.2'
  provided 'javax.annotation:jsr250-api:1.0'
  compile 'com.github.pwittchen:reactivenetwork:0.5.0'
  testCompile "junit:junit:4.12"
  testCompile "org.mockito:mockito-all:1.10.19"
  compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
    transitive = true;
  }
  debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
  releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
  testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
}

我所做的就是将一个版本号从24.1.1改为24.2.0,如下所示:

代码语言:javascript
复制
dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')

  compile 'com.android.support:recyclerview-v7:24.2.0'

  compile 'com.android.support:multidex:1.0.1'
  compile 'com.android.support:cardview-v7:24.2.0'
  androidTestCompile 'com.android.support:support-annotations:24.2.0'
  androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
  androidTestCompile 'com.android.support.test:runner:0.5'
  compile 'com.github.siyamed:android-shape-imageview:0.9.3@aar'
  compile 'com.neovisionaries:nv-websocket-client:1.12'
  compile 'com.nightonke:jellytogglebutton:1.0.2'
  compile 'com.squareup.okhttp3:okhttp:3.4.0-RC1'
  compile 'com.squareup.picasso:picasso:2.5.2'
  compile 'de.greenrobot:eventbus:2.4.0'
  compile 'de.hdodenhof:circleimageview:2.0.0'
  compile('com.github.ozodrukh:CircularReveal:1.3.1@aar') {
    transitive = true;
  }
  compile 'com.jakewharton:butterknife:8.1.0'
  apt 'com.jakewharton:butterknife-compiler:8.1.0'
  compile 'io.reactivex:rxandroid:1.2.1'
  compile 'io.reactivex:rxjava:1.1.6'
  compile "com.github.fge:json-patch:1.9"
  apt 'com.squareup:javapoet:1.7.0'
  apt 'com.google.dagger:dagger-compiler:2.2'
  compile 'com.google.dagger:dagger:2.2'
  provided 'javax.annotation:jsr250-api:1.0'
  compile 'com.github.pwittchen:reactivenetwork:0.5.0'
  testCompile "junit:junit:4.12"
  testCompile "org.mockito:mockito-all:1.10.19"
  compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
    transitive = true;
  }
  debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
  releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
  testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
}

如果进行此更改,则生成失败,并出现以下错误:

代码语言:javascript
复制
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/view/PagerTitleStrip$PageListener.class

我尝试为支持模块设置不同的排除,并尝试使用不同的前缀进行编译(比如androidTestCompile与compile)。

如果有人能理解,如果发生了什么,帮助我,我将永远感激。谢谢。

EN

回答 2

Stack Overflow用户

发布于 2016-09-08 16:01:27

将此添加到build.gradle文件中,您将具有重复的依赖关系,因此这将排除冲突。

代码语言:javascript
复制
configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}

如果上面不起作用,那么你可以简单地做

代码语言:javascript
复制
compile ('com.android.support:recyclerview-v7:+') {
    exclude module: 'support-v4'
}
票数 1
EN

Stack Overflow用户

发布于 2016-09-08 16:01:18

在Android或gradle命令中清理和重建该项目。

命令在gradle中这样做

./gradlew clean

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39395295

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档