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

Android studio 打包时报错如下:

Cannot fit requested classes in a single dex file. Try supplying a main-dex list.
# methods: 66585 > 65536
Message{kind=ERROR, text=Cannot fit requested classes in a single dex file. Try supplying a main-dex list.
# methods: 66585 > 65536, sources=[Unknown source file], tool name=Optional.of(D8)}
 

解决方法:

在build.gradle下的

defaultConfig下加入
multiDexEnabled true

如:

defaultConfig {
    applicationId "com.tianxin.mapclient.liteapp"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 19
    versionName "19.0"

    multiDexEnabled true

    javaCompileOptions {

        annotationProcessorOptions { includeCompileClasspath = true }
    }

    ndk {
        abiFilters "armeabi", "x86", "x86_64", "mips64", "mips"
    }

    manifestPlaceholders = [
            JPUSH_PKGNAME : applicationId,
            JPUSH_APPKEY : "880fe88703ab92260d7d42ca", //JPush上注册的包名对应的appkey.
            JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
    ]
}

猜你喜欢

转载自blog.csdn.net/meixi_android/article/details/81204319