does resolutionStrategy affect the dependent lib

Having a project which itself is using supportLib version 0f 27.1.1.

It has dependencies on a few libs, not sure from which one causes this error:

Execution failed for task ':demo:processDebugManifest'. Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.2) from [com.android.support:support-emoji-appcompat:26.0.2] AndroidManifest.xml:25:13-35 is also present at [com.android.support:percent:26.1.0] AndroidManifest.xml:25:13-35 value=(26.1.0). Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:23:9-25:38 to override.

after added this resolutionStrategy:

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "${versions.support}"  //<== versions.support is 27.1.1
            }
        }
    }
}

the error goes away.

I guess it says this project should be using 27.1.1 regardless if there is dependencies who may use different one.

Question is will this also force the dependent libs to use 27.1.1, which may not be work against this version of 27.1.1?

or it only affects this project itself?

1 answer

  • answered 2018-07-11 21:37 Martin Zeitler

    it changes the version numbers for requested group com.android.support and there are no "different versions" of version 27.1.1. one can also define the version numbers in the Manifest.xml <application> tag, with tools:replace:

    <meta-data
       android:name="android.support.VERSION"
       android:value="27.1.1"
       tools:replace="android:value"/>