Android. What is the purpose of multiDexKeepProguard? How does it compare to proguardFiles in gradle?

I have created a multi-user app. But regarding proguard, I have the following in build.gradle:

    android {
    defaultConfig {
        ...
        multiDexEnabled true
    }
    productFlavors {
        dev {
            // Enable pre-dexing to produce an APK that can be tested on
            // Android 5.0+ without the time-consuming DEX build processes.
            minSdkVersion 21
        }
        prod {
            // The actual minSdkVersion for the production version.
            minSdkVersion 14
        }
    }
    buildTypes {
        release {
            minifyEnabled true
        ***    proguardFiles getDefaultProguardFile('proguard-android.txt'),
                                                 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile 'com.android.support:multidex:1.0.1'
}

      

My question is about progardFiles and using multiDexKeepProguard . The documentation states:

MultiDexKeepProguard File

A text file with additional ProGuard rules that will be used to determine if classes are compiled into the main dex file.

If set, the rules from this file are used in conjunction with the default rules used by the build system.

So if I am not using multiDexKeepProguard then my classes will still compile but may not end up in the main dex file, is that correct? I don't quite understand how this differs from proguardFiles.

The Android documentation refers to this as well .

+3


source to share


1 answer


If you include proguard in your application, you usually need to define proguard rules. proguardFiles

should be instructions for the programmer to minify or obfuscate your application.



multiDexKeepProguard

is designed specifically to tell multidex which files are important to load when the application starts up and therefore what to store in the main dex. As far as I know, it is just using proguard syntax as a convenience. This is optional and is usually only installed if there is a problem at runtime.

+2


source







All Articles