解决 The same input jar is specified twice 问题

阿里云产品限时红包,最高 ¥1888 元,立即领取
1
2
Execution failed for task ':joke:proguardRelease'.
> java.io.IOException: The same input jar [/Users/lfy/Develop/gits/joke-android/joke/libs/eventbus.jar] is specified twice.

今天在打混淆包时,遇到这个错误,刚开始以为是因为有多个项目都引用了 eventbus.jar 库,但当我对项目中的 eventbus.jar 的依赖进行排除时,同样出错。这次报的则是没有 eventbus.jar。 所以打消了我的第一个猜测。

后来发现,是因为以前在用 eclipse 开发时,混淆配置文件中包含有 -libraryjars libs/eventbus.jar 的配置,用来保持 eventbus.jar 不被混淆。在 Android Studio 中, build.gradle 中声明了对这个 jar 包的依赖,则不需要在混淆配置文件中继续声明。

在将所有的 -libraryjars libs/*.jar 注释掉以后,项目可以正常混淆了。