继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

Android Studio 3.1.1 打Jar包出现AGPBI异常解决

拉丁的传说
关注TA
已关注
手记 609
粉丝 126
获赞 789

今天,写好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://help.gradle.org

BUILD FAILED in 0s20 actionable tasks: 1 executed, 19 up-to-date10:36:12: Task execution finished 'exportJar'.

网上搜索,发现很多人都说包重复引用导致,但是LZ这是一个简单得Demo,并没有依赖太多项,况且,有的小伙伴说,需要分包,LZ瞬间很是不解,毛都没,分个啥?

随后,果断检查代码,查看是不是由于疏忽导致这种问题,果然:

图片描述

打包时,LZ忘记将application:

apply plugin: ‘com.android.application’

修改为library:

apply plugin: ‘com.android.library’

实属尴尬啊~

吐槽下Bus编辑器,难用要死。。。噗

原文链接:http://ttp://www.apkbus.com/blog-904057-77618.html

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP