1.在App的build.gradle文件里面级别为defaultConfig里添加
multiDexEnabled true
示例: defaultConfig { applicationId "com.lxkj.qlyigou" minSdkVersion 16 targetSdkVersion 27 versionCode 101 versionName "1.0.1" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true }
2.加入依赖
implementation 'com.android.support:multidex:1.0.3'
3.Applocation进行初始化
@Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); }
4.不要忘记注册Applocation!!!