android/support/v4/hardware/display/DisplayManagerCompat$JellybeanMr1Impl.class

来源:互联网 发布:德川家光 知乎 编辑:程序博客网 时间:2024/06/05 02:20

题引:同事需要使用第三方库,由于这些第三方库使用的v4包版本跟我们编写的项目所使用的v4包版本不同而导致了一个bug(duplicate entry) 。

  • 引入recyclerview-swipe
  • 引入butterknife
  • bug来了
  • Instant Run

某同事引入recyclerview-swipe和butterknife

compile 'com.yanzhenjie:recyclerview-swipe:1.0.2'compile 'com.jakewharton:butterknife:8.5.1'

bug来了

* What went wrong:Execution failed for task ':yangsheng:transformClassesWithJarMergingForDebug'.> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/hardware/display/DisplayManagerCompat$JellybeanMr1Impl.class
奇怪的是,其他同事并没有报错!!!

Instant Run

最终发现同事没有报错是因为开启了Instant Run,因为Instant Run会自动过滤包冲突。

解决思路

刚开始,以为是引入recyclerview-swipe导致的,因为recyclerview-swipe使用的v4包跟我们项目使用的v4包版本不同。修改gradle如下:
compile('com.yanzhenjie:recyclerview-swipe:1.0.2') {        exclude module: 'recyclerview-v7'}
然而并没有什么卵用!!!
终于发现问题了,是引入butterknife导致的bug,gradle修改如下:
compile('com.jakewharton:butterknife:8.5.1') {        exclude module: 'support-compat'}
最终编译成功通过并且能够安装运行。

0 0
原创粉丝点击