Getting MultiDex Error, even after setting Min SDK 21

北城余情 提交于 2019-12-06 05:32:48

问题


The project i am working on has around 180k Methods. I have read blogs, and articles where its written that if you set your Min SDK to 21, then you don't need MultiDex. But if i remove MultiDex from here it gives me the 65k MultiDex error message. Following is my gradle file. I don't know whether i failed to understand the concept or something else. Kindly guide me.

compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {

    applicationId 'com.myapp.app'
    minSdkVersion 21
    targetSdkVersion 23
    versionCode 59
    versionName "1.0.1"
    multiDexEnabled true
    ndk {
        abiFilters "armeabi", "armeabi-v7a", "x86"
    }
}
dexOptions {
    javaMaxHeapSize "4g" //specify the heap size for the dex process
}
lintOptions {
    abortOnError false
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

productFlavors {
} 

回答1:


if you set your Min SDK to 21, then you don't need MultiDex

As per the "Multidex support for Android 5.0 and higher" instructions in the MultiDex guide, even if you minSdk 21 then you still need compile with multiDexEnabled true. What you don't need to do is include the MultiDex support library via:

compile 'com.android.support:multidex:1.0.0'

or call MultiDex.install(Context) in your Application class.

The 64K method problem is a limitation of the DEX file format and not of the Android Platform itself. The difference between the two versions is that Android 5.0+ knows how to automatically load multiple DEX files into a single OAT file and load classes from it while Android versions prior to 5.0 require the support library in order to load classes from secondary DEX files (e.g. classes2.dex, classes3.dex, etc).



来源:https://stackoverflow.com/questions/40309249/getting-multidex-error-even-after-setting-min-sdk-21

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!