Cannot fit requested classes in a single dex file. Try supplying a main-dex list.

最近接手的项目中,遇到了好几次这个问题。都是由依赖第三方库jar包引发的,可以通过修改app的build.gradle文件解决该错误。
添加依赖:

dependencies {
    implementation 'com.android.support:multidex:1.0.3'
}

在defaultConfig中添加以下属性

multiDexEnabled true

如果定义了Application子类,还需做额外操作,具体参考https://stackoverflow.com/questions/48249633/errorcannot-fit-requested-classes-in-a-single-dex-file-try-supplying-a-main-dex

你可能感兴趣的:(Cannot fit requested classes in a single dex file. Try supplying a main-dex list.)