Enable Multidex in Android Application

Updated 22 September 2023

Save

What is multidex file and why we need for the APK file?

Android application (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536, including Android framework methods, library methods, and methods in your own code. Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration.

How to configure our application for multidex?

If ourminSdkVersion is set to 21 or higher, all we need to do is set multiDexEnabled to true in our module-level build.gradle file, as shown here:

however if our min Sdk Version is less than 21 then we need to following two steps to configure multidex.

step 1:- Modify the module-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:

step 2:- Depending on whether we override the Application class, perform one of the following:

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home