Skip to content

Instantly share code, notes, and snippets.

@im182cm
Last active December 6, 2017 04:26
Show Gist options
  • Save im182cm/b72d9e4de22c81ca5c4ce3d7bd9a577f to your computer and use it in GitHub Desktop.
Save im182cm/b72d9e4de22c81ca5c4ce3d7bd9a577f to your computer and use it in GitHub Desktop.
How to exclude gradle dependencies

Volume down apk size with gralde exclude

Why Should I use it?

  1. cause of multidex problem
    Some of apps doesn't support multidex option, due to support low version below Lollipop.
    In my case, I was using Facebook SDK to implement social login, but with recent version of SDK, v4.28. My app's method counts was over to 65K. However I was supporting from Kitkat, so I should exclude some libraries not using.
  2. To reduce apk size

How can I do that?

  1. make configurations blocks with any name and change compile to the name.
configurations {
    test
}

dependencies {
    test (project(':facebook-login'))
}
  1. type below codes in terminal
./gradlew app:dependencies --configuration test
  1. see dependencies list and exclude group and module like below
dependencies {
    compile (project(':facebook-login')){
        exclude group: 'com.android.support', module: 'support-compat'
        exclude group: 'com.android.support', module: 'support-fragment'
        exclude group: 'com.android.support', module: 'support-media-compat'
        exclude group: 'com.android.support', module: 'support-core-ui'
        exclude group: 'com.android.support', module: 'support-core-utils'
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment