All Products
Search
Document Center

Notes on using multidex for mPaaS Inside projects

Last Updated: Mar 10, 2021

About this topic

MultiDex is a solution to the problem that the number of Dex methods or types for the earlier versions of Android 5.0 exceeds 65535. In the case of the bloating appliation features at the moment, we need to plan for the Dex.Because the mPaaS access method is based on the bundle, the bundle will try to combine once with the user’s Dex when the bundle packages. However, mPaaS will ensure the first Dex sequence of the user. In this case, in order to access to mPaaS, avoid adding excessive logic in the Application and make the first dex as small as possible. You can use the --main-dex-list parameter to specify your type in the first Dex. For example, if the first Dex types are excessive in your APK, some necessary bundles in mPaaS will fail to combine. As a result, the framework may fail to start in the running environment earlier than Android 5.0. That is, the problems of ClassNotFound or ClassNotDef.

Notes

  1. When you access to the mPaaS Inside, we have provided MultiDex. Thus, you can delete the MultiDex provided officially from the implementation.
 
  1. dependencies{
  2. implementation 'com.android.support:multidex:1.0.3' //Delete this line
  3. }
 
  1. Meanwhile, you are suggested to add `multiDexEnabled true` under the `android` module of the gradle.
 
  1. android {
  2. defaultConfig {
  3. multiDexEnabled true
  4. }
  5. }
  1. If you are using the mPaaS Inside, and not accessing to the hotfix, while MultiDex is needed to support, you have to call MultiDex.install(this) in the Application.
 
  1. public class App extends Application() {
  2. public void attachBaseContext(Context context) {
  3. super.attachBaseContext(context);
  4. MultiDex.install(this);
  5. }
  6. }
  1. If you are using the hotfix, namely, using the QuinoxlessApplication, you do not need to perform explicit call in the code.