MultiDex示例:
AndroidStudio中MultiDex配置:
1、grandle配置
multiDexEnabled true // true时,生成多个dex
setMultiDexKeepFile file("multiDexKeep.txt") // 当前项目中指定的classes,编译到class.dex中
implementation "com.android.support:multidex:1.0.1"
2、multiDexKeep.txt文件生成
path=%~dp0
cd path
dir /a-d /b /s > multiDexKeep.txt
3、Application中调用MultiDex
package com.ltsdk.union;
import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;
// 自定义 Application
public class LtsdkApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this); // 调用MutiDex
}
}