4

In my gradle.build, I have various library that perform the same exclusion as below

androidTestCompile ('com.android.support.test:runner:0.5') {
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test:rules:0.5')  {
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test.espresso:espresso-web:2.2.2') {
    exclude group: 'com.android.support', module: 'support-annotations'
}

Obviously, everyone is using the same exclude

    exclude group: 'com.android.support', module: 'support-annotations'
}

Is there a way, that I need only to write the exclude once, and apply to all libraries (at least those that I am interested to perform exclusion)?

Elye
  • 53,639
  • 54
  • 212
  • 474
  • For others looking for a way to force one version only without adding the exclude to other libraries, check [this post](https://stackoverflow.com/q/37347326/4625829) – AL. May 09 '19 at 06:34

1 Answers1

1

There is a config to excude for all instance in project:

configurations.all { exclude ... }
mdtuyen
  • 4,470
  • 5
  • 28
  • 50
  • Where should I put this config? I tried in build.gradle, but it complaints `Method call is ambiguous` – Elye Jul 12 '16 at 02:05
  • in android{}, please – mdtuyen Jul 12 '16 at 02:07
  • It works, but it is complaining, `Method call is ambiguous`. Is this something of concern? – Elye Jul 12 '16 at 04:24
  • Found this. http://stackoverflow.com/questions/25177361/gradle-configurations-all-ambiguous. Upvote the answer. Waiting to see if there's other answer before ticking this. – Elye Jul 12 '16 at 04:26