ARouter踩坑之'Program type already present: com.alibaba.android.arouter.routes.ARouter$$Group$$My'

钦宏义
2023-12-01
Program type already present: com.alibaba.android.arouter.routes.ARouter$$Group$$MyRouter2
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
	at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:131)
	at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:118)
	at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:102)
	at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:37)
	at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
	... 4 more
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
	at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:81)
	at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:45)
	at com.android.tools.r8.D8.run(D8.java:94)
	at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:116)
	... 7 more
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: com.alibaba.android.arouter.routes.ARouter$$Group$$MyRouter2
	at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:101)
	at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:72)
	at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:66)
	... 10 more

原因是

@Route(path = "/MyRouter2/ARouter2Activity")
@Route(path = "/MyRouter2/ARouter3Activity")

多个module中不能使用同一个group(MyRouter2)否则会报类型重复

也即每个module中都要有各自的group,不能重复。

 类似资料: