How to enable multidexing with the new Android Multidex support library

后端 未结 14 2412
逝去的感伤
逝去的感伤 2020-11-21 12:57

I want to use the new Multidex support library to break the method limit for one of my apps.

With Android Lollipop Google introduced a multidex support library that

14条回答
  •  失恋的感觉
    2020-11-21 13:52

    Here is an up-to-date approach as of October 2020, with Android X. This comes from Android's documentation, "Enable multidex for apps with over 64K methods."

    For minSdk >= 21

    You do not need to do anything. All of these devices use the Android RunTime (ART) VM, which supports multidex natively.

    For minSdk < 21

    In your module-level build.gradle, ensure that the following configurations are populated:

    android {
        defaultConfig {
            multiDexEnabled true
        }
    }
    
    dependencies {
        implementation 'androidx.multidex:multidex:2.0.1'
    }
    

    You need to install explicit multidex support. The documentation includes three methods to do so, and you have to pick one.

    For example, in your src/main/AndroidManifest.xml, you can declare MultiDexApplication as the application:name:

    
        
    
    

提交回复
热议问题