我在接入阿里云的hotfix热修复时运行项目出现了:
Error:FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
通过查找我发现是build.gradle里面出现了相同的依赖包引用或者是lib里的jar文件引用重复了,或者不同的包有包含的关系!
知道问题就好办了:
1,看看是否有重复的依赖包,有的话删除一个
2,
android {
defaultConfig {
multiDexEnabled true
}
开启dex合并(但是我一开始是开启了的还是报这个错误)
以上两个在我的代码都排除了没有问题,那就是不同的包或者不同的jar文件,或者依赖包与jar包有包含关系,然后我就开始找果然找到了,原来是阿里的utdid包重复了因为我的项目中介入了支付宝支付,这两个sdk中都包含了utdid这个包然后就把这个包在移动热修复中的依赖剔除掉.
implementation('com.aliyun.ams:alicloud-android-hotfix:3.2.8') {
exclude(module: 'alicloud-android-utdid')
}
阿里云文档中也有这个的解决办法:https://help.aliyun.com/knowledge_detail/59152.html?spm=a2c4g.11186623.2.10.5313174aHlWk7x
写的不好 ,纯属个人问题错误的记录,以此加深印象!!!