集成了许多jar包,然后android studio编译时报如下错误:

Task :SystemUI_Full:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
AGPBI: {“kind”:“error”,“text”:“Program type already present: com.hp.hpl.sparta.Node”,“sources”:[{}],“tool”:“D8”}

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:SystemUI_Full:transformDexArchiveWithExternalLibsDexMergerForDebug’.
    com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: D:\compile\svnProjects\SystemUI_Full\build\intermediates\transforms\dexBuilder\debug\127.jar, D:\compile\svnProjects\SystemUI_Full\build\intermediates\transforms\dexBuilder\debug\128.jar, D:\compile\svnProjects\SystemUI_Full\build\intermediates\transforms\dexBuilder\debug\129.jar, D:\compile\svnProjects\SystemUI_Full\build\intermediates\transforms\dexBuilder\debug\130.jar, D:\compile\svnProjects\SystemUI_Full\build\intermediates\transforms\dexBuilder\debug\126.jar, D:\compile\svnProjects\SystemUI_Full\build\intermediates\transforms\dexBuilder\debug\65.jar

解决方案:将implementation改为compileOnly,避免将依赖的模块重复把jar编译进apk里。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐