今天,写好Demo兴致勃勃准备打个Jar包在Unity中测试下,不料,突然出现AGPBI这个异常,日志如下:
AGPBI: {"kind":"error","text":"Program type already present: android.support.v4.app.BackStackRecord$Op","sources":[{}],"tool":"D8"}
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
AGPBI: {"kind":"error","text":"Program type already present: android.support.v4.app.BackStackRecord$Op","sources":[{}],"tool":"D8"}
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\0.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\1.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\2.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\3.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\4.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\5.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\6.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\7.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\8.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\9.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\10.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\11.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\12.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\13.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\14.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\15.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\16.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\17.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\18.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\19.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\20.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\21.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\22.jar, E:\AiYouDemo\UcenterSdkTest\app\build\intermediates\transforms\dexBuilder\debug\23.jar
* 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://
BUILD FAILED in 0s
20 actionable tasks: 1 executed, 19 up-to-date
10:36:12: Task execution finished 'exportJar'.
网上搜索,发现很多人都说包重复引用导致,但是LZ这是一个简单得Demo,并没有依赖太多项,况且,有的小伙伴说,需要分包,LZ瞬间很是不解,毛都没,分个啥?
随后,果断检查代码,查看是不是由于疏忽导致这种问题,果然:
打包时,LZ忘记将application:
apply plugin: ‘com.android.application’
修改为library:
apply plugin: ‘com.android.library’
实属尴尬啊~