> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

时间:2023-03-09 02:48:29
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Cannot fit requested classes in a single dex file (# methods: > 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:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

解决方法:在android/app/build.gradle文件中添加> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

multiDexEnabled true(写在defaultConfig对象中)