From the documentation, I read that there are two ways to support MultiDex in devices below API 21:
MultiDexApplication
, andMultiDex.install(this)
in the Application class's onAttachBaseContext(Context base)
function in case the Application extends something else.Are they basically the same with extending MultiDexApplication
calling MultiDex.install(this)
in the onAttachBaseContext()
by default, or are there differences between both methods?
they are two ways to enable multidex for your app and they are completely same
if you want to create a class for application just for enable multidex you can just put MultiDexApplication for application name in AndroidManifest and don't need to do more because in MultiDexApplication overrided attachBaseContext() , look :
public class MultiDexApplication extends Application {
public MultiDexApplication() {
}
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
and if you have application class end it extends just Application you also can change extends to MultiDexApplication instead of ovverride attachBaseContext() method , otherwise you have application class that it doesn't extends from Application, so you have to override attachBaseContext() and your custom Application class