Skip to content

Patched mainTemplate.gradle contains multiple versions of the same dependency #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
glodos opened this issue Jun 25, 2019 · 2 comments
Closed

Comments

@glodos
Copy link

glodos commented Jun 25, 2019

Not sure if anyone has reported it yet, but one of the reasons our build failed after updating the resolver was adding duplicate dependencies with different versions when patching of mainTemplate.gradle file is enabled.

Our project contains many third party SDKs that depend on play services or android support libraries. Each SDK has its dependencies defined in the xml file or added dynamically in code. Dependency versions are different across SDKs, which is a normal thing. However, the resolver fails to pick only one dependency with highest version. Instead it picks each dependency and adds it to the mainTemplate.gradle file resulting in this:

...
implementation 'com.android.support:support-v4:25.3.1'
implementation 'com.android.support:support-v4:27.1+'
...

This results in failed build due to duplicate class definitions. We have to manually set dependency versions in xml files and source of third party SDKs to avoid this error. This case should be handled by the resolver by picking highest version automatically and ignoring other duplicate dependencies. Currently running resolver v1.2.119.0

@stewartmiles
Copy link
Contributor

@glodos yes this is the way the Android Resolver currently works when patching mainTemplate.gradle . If you want the behavior where the resolver tries to select the compatible packages across a range of plugins you'll have to turn off mainTemplate.gradle patching in the settings menu.

I guess a way to support this would be to run the old resolution step first, which would download libraries into the project, then use the output of the process to determine which packages were selected and instead inject those into mainTemplate.gradle.

@Deepscorn
Copy link

Highly appreciate the things, you guys are doing! Will wait for this feature finished

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants