不知不觉中维护的项目加上第三方依赖库方法数已经快超出64K方法数的限制了.
Total methods in app-release.apk: 58827 (89.76% used)
Total fields in app-release.apk: 35986 (54.91% used)
Methods remaining in app-release.apk: 6708
Fields remaining in app-release.apk: 29549
是时候引入Multidex来解决这个方法数限制
1.在module build.gradle中加入
android {
...
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
2.如果你不希望在Mainfest.xml文件中引用MultiDexApplication作为Application类,或者你已经有自己的自定义Application类,那么在你的Application类的onBaseContextAttached方法中加入MultiDex.install(this);
@Override
public void onBaseContextAttached(Context base) {
super.onBaseContextAttached(base);
MultiDex.install(this);
....
}
网友评论