版权声明:个人学习记录,由于能力和时间有限,如果有错误望读者纠正,谢谢! 转载请注明出处 谢谢合作 https://blog.csdn.net/qq_43377749/article/details/87177478
原因:
随着 Android 平台的持续成长,Android 应用的大小也在增加。当您的应用及其引用的库达到特定大小时,您会遇到构建错误,指明您的应用已达到 Android 应用构建架构的极限。早期版本的构建系统按如下方式报告这一错误:
错误提示:
较早版本 Android :
Conversion to Dalvik format failed:
Unable to execute dex: method ID not in [0, 0xffff]: 65536
较新 Android 版本:
trouble writing output:
Too many field references: 131000; max is 65536.
You may try using --multi-dex option.
解决方案:
app:gradle 中添加依赖:
implementation 'com.android.support:multidex:1.0.1'
详细原因以及解决方案参见:
官网:https://developer.android.com/studio/build/multidex?hl=zh-cn