Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Multidex with Gradle

    • 0
    • 2
    • 0
    • 0
    • 5
    • 0
    • 0
    • 0
    • 346
    Comment on it

    APK uses executable bytecode i.e Dalvik Executable (DEX) files to run an app. The dex file limits the total number of methods in a single dex file to 65,536, including Android sdk methods, library methods, and methods in our code. But sometimes it exceeds limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration.

    so to enable multidex functionality we uses multiDexEnabled true in our app gradle.

    And this support library works on 5.0 or higher version.

    so to support in lower version we uses following steps -

    1. In your Manifest file add this in application tag

      android:name="android.support.multidex.MultiDexApplication" 
      
    2. In your App gradle file add this dependency

      compile 'com.android.support:multidex:1.0.0'
      

    Now you can also use multidex in lower versions.

 5 Comment(s)

  • @rohit.puri you still taking me wrong, using your code multidex will be applicable for only api 14 but i dont want to put an api check, rather i want to put check on my apps different flavors, so please help me with that.....

  • @Anupriya you should create an Application class that will extend Application and in onBaseContext you can run multidex if flavor or api version match like this :

    public class YouApplication extends Application {
    
        @Override
        protected void attachBaseContext(Context base) {
            super.attachBaseContext(base);
            if (android.os.Build.VERSION.SDKINT ==  14) {
            MultiDex.install(this);
            }
        }
    
  • By including android:name="android.support.multidex.MultiDexApplication" in your application Tag, you are making it available for your whole application, but what if i want to make it applicable for only one of the flavors of my app?

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: