Gradle To Force Dependencency Library Version

May 18, 2018

You might be using 3rd party library who are using a different version of android support library. Use the following configuration to force all dependency libraries to use the same version.

Edit project's build.gradle.

buildscript {
    ext {
        android_support_library_version = '27.1.1'
    }

    ...
}

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && details.requested.name != 'multidex'
                    && details.requested.name != 'multidex-instrumentation') {
                details.useVersion android_support_library_version
            }
        }
    }
}

References:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.