Two of the components of an android application depends on two different versions of the same Library. (google protobuf).
ie. Module 1 depends on protobuf2, while Module 2 needs protobuf3.
The required parts of the the two versions are mutually exclusive and hence not interchangeable.
So far gradle internally use the lastest version from the two versions and one module breaks at a missing method.
Is it possible to force gradle to use version 2 for the 2's dependent and version 3 for the 3's dependent? Or else what are the possible alternatives to address this sort of an issue?
Cheers.
I guess, if you are having different build.gradle files for your respective modules and these modules are linked by some parent build.gradle file, then there should not be any issue.
I'm not an expert on gradle but using maven for a long time and these are somehow similar in nature.
In maven, I can declare the same dependency with different versions in different module's pom file :
In another, pom file you can declare different versions :
Now, you can see two different versioned jars will get added under '
Maven-dependencies
' of different modules.In same pom file it won't be possible without using profiling. Otherwise it will always pick the jar which is nearest to it's dependency tree out of 2-3 different version jars.