:
stderr[
D8: Cannot fit requested classes in a single dex file (# methods: 93859 > 65536)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':launcher:transformDexArchiveWithExternalLibsDexMergerForRelease'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.熟悉Android开发的同学对这个错误应该不陌生,Android 5.0之前的版本(API level < 21)使用Dalvik runtime 来执行代码,默认限制每个APK 只能使用一个classes.dex 文件,而DEX规范又将单个DEX文件内引用的方法总数限制为65536个,所以如果你游戏中使用了较多的第3方SDK,很容易就会超过这个限制。
这个问题我们之前也遇到过,解决的方法有三种: