How to enable multidexing with the new Android Multidex support library

后端 未结 14 2411
逝去的感伤
逝去的感伤 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:43

    In your build.gradle add this dependency:

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

    again in your build.gradle file add this line to defaultConfig block:

    multiDexEnabled true
    

    Instead of extending your application class from Application extend it from MultiDexApplication ; like :

    public class AppConfig extends MultiDexApplication {
    

    now you're good to go! And in case you need it, all MultiDexApplication does is

    public class MultiDexApplication extends Application {
        @Override
        protected void attachBaseContext(Context base) {
            super.attachBaseContext(base);
            MultiDex.install(this);
        }
    }
    

提交回复
热议问题