Tag Archives: Technology sharing

Android dependency merge rules

  1. Remote dependency merge rule

If multiple modules depend on the library in the way of [implementation + coordinates], only one version will be compiled, and it is the latest version

module A: 
implementation "com.fengma.tool:gradle-tool:2.1.2"
...
module B:
implementation "com.fengma.tool:grdle-tool:2.3.3" //gradle default the latest version

If you want to change the default compile version selection, you can specify a version by using gradle’s dependency selection mechanism

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'com.fengma.tool') {
            details.useVersion '2.1.2'
            details.because 'Use Lower version'
        }
    }
}

2. Local plus remote dependency mode

When module a introduces a jar package in the way of [local lib], and module B introduces the same library in the way of [implementation + coordinates], it will cause compilation conflicts and lead to compilation failure. Therefore, it is necessary to unify the dependency mode.

module A:
compile files('libs/fengma-tool-2.1.2-.jar')
...
module B:
compile "com.fengma.tool:grdle-tool:2.3.3"
... Compilation conflicts, class duplication