擴充套件應用程式的 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>