title: How to manage different support library versions for 3rd party deps with gradle?
body: <p>I have a bunch of third party libs that I include in my base application.  I cannot control the support library those 3rd party modules include. This makes it hard to have the same version of the android support library in my application.</p>
  
  <p>I know using gradle when I can exclude certain libraries from each dependency:</p>
  
  <pre><code>compile('com.test:lib1:1.0.0') {
      exclude group: 'com.android.support'
  }
  </code></pre>
  
  <p>However there are a ton of support libraries and excluding them all for each one of my 3rd party libraries seems like overkill.</p>
  
  <p>Is there a better way?</p>
  
  <p>Reading this blog post: <a href="https://www.devsbedevin.net/android-understanding-gradle-dependencies-and-resolving-conflicts/" rel="nofollow noreferrer">https://www.devsbedevin.net/android-understanding-gradle-dependencies-and-resolving-conflicts/</a></p>
  
  <p>It suggests:</p>
  
  <pre><code>configurations.all {
    resolutionStrategy {
      preferProjectModules()
    }
  }
  </code></pre>
  
  <p>However when using that I still get a warning in Android Studio in my gradle file that there are multiple versions of the support library detected.</p>
  
  <p>What do I do if my dependencies depend on different versions of the support library?  In either case above I would be forcing the 3rd party libraries to use a specific version of the support library that they were not build with.  Which version am I supposed to use? Latest support library?  Min support library of all 3rd party dependencies?</p>
  
  <p>Here is a minimal gradle file example showing pulling in 3rd party dependencies that each depend on their own version of the support library.</p>
  
  <pre><code>android {
      compileSdkVersion 26
      buildToolsVersion '26.0.2'
  
      defaultConfig {
          applicationId "com.example.app"
          minSdkVersion 17
          targetSdkVersion 25
      }
  }
  
  configurations.all {
      resolutionStrategy {
          preferProjectModules()
      }
  }
  
  dependencies {
      compile 'com.android.support:support-v13:26.0.0'
      compile 'com.test:lib1:1.0' // depends on support-v13:25.0.0
      compile 'com.test:lib2:1.0' // depends on support-v13:25.2.0
      compile 'com.test:lib3:1.0' // depends on support-v13:25.4.0
      compile 'com.test:lib4:1.0' // depends on support-v13:26.0.0
  }
  </code></pre>
  
  <p>Android studio gives the following warning:</p>
  
  <p><a href="https://i.stack.imgur.com/wqQxA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wqQxA.png" alt="enter image description here"></a></p>