All Products
Search
Document Center

Mobile Platform as a Service:Attentions for using multidex in mPaaS Inside projects

Last Updated:Oct 14, 2022

MultiDex is a solution to the problem that the number of Dex methods or classes in the versions earlier than Android 5.0 exceeds 65535. In the case of the bloating appliation features at the moment, we need to make planning 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.

Attentions

  • When you access the mPaaS Inside projects, we have provided MultiDex. Thus, you can delete the official MultiDex from the implementation.

      dependencies{
           implementation 'com.android.support:multidex:1.0.3' //Delete this line
      }

    Meanwhile, you are suggested to add multiDexEnabled true under the android module of the gradle.

      android {
          defaultConfig {
            multiDexEnabled true
          }
      }
  • If you are using the mPaaS Inside, and not accessing to the hotfix, while MultiDex is needed, you have to call MultiDex.install(this) in the Application.

      public class App extends Application() {
          public void attachBaseContext(Context context) {
              super.attachBaseContext(context);
              MultiDex.install(this);
          }
      }
  • If you are using the hotfix, namely, using the QuinoxlessApplication, you do not need to perform explicit call in the code.