扩展应用程序的 Multidex
如果你的项目需要 Application 子类,请使用此选项。
使用 application 标记内的 manifest 文件中的 android:name 属性指定此 Application 子类。
在 Application 子类中,添加 attachBaseContext() 方法重写,并在该方法中调用 MultiDex.install():
package com.example;
import android.app.Application;
import android.content.Context;
/**
* Extended application that support multidex
*/
public class MyApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
确保在 AndroidManifest.xml 的 application 标记中指定了 Application 子类:
<application
android:name="com.example.MyApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
</application>