Android studio Cannot fit requested classes in a single dex file (# methods: 77504 > 65536)

Flutter kotlin编译错误

Execution failed for task ‘:app:mergeDexDebug’.
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
> There was a failure while executing work items
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
> 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

* 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.

解决方法如下:

应用内级别build.gradle添加:

android {
    defaultConfig {
        ...
        multiDexEnabled true
    }
}

dependencies {
  implementation 'com.android.support:multidex:1.0.3'
}
此条目发表在服务器分类目录,贴了, 标签。将固定链接加入收藏夹。

发表回复