首先遇到客戶遇到的問題是這樣的:
- 很明顯的錯誤提示是:Unable to merge dex;
- 翻譯過來就是:無法合並。
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
最開始以為是導包之后數量超了導致的。原本給介紹的解決辦法是:
https://developer.android.com/studio/build/multidex.html
如下圖所示:
后來更改之后提示的錯誤又變了,如下圖:
才知道上面提到的不是問題的關鍵,關鍵是這里的提示信息,明顯的提示文件重復。
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [D:\AndroidWork\xb\XBDemo\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [D:\AndroidWork\xb\XBDemo\app\libs\UHF_API_JAR.jar(;;;;;;**.class)] (Duplicate zip entry [UHF_API_JAR.jar:com/uhf/uhf/UHF1/UHF1Application.class]))
- 最后遠程查看了他的代碼,確實是jar包重復導致的問題: