0

I updated SDK yesterday and after project sync I got next message:

Error:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.2.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

I suppose Android Studio tries to use latest dependencies even I didn't change my Gradle files. How to workaround it?

Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114
  • 1
    http://stackoverflow.com/questions/33317555/conflict-with-dependency-com-android-supportsupport-annotations-resolved-ver/33318482#33318482 – Gabriele Mariotti Feb 26 '16 at 06:25
  • Thank you for suggestion. It is clear what happens. I don't use `23.2.0` directly. I'm trying to find which dependency is forcing to for newer support. – Eugen Martynov Feb 26 '16 at 06:27
  • 1
    I found the issue. One of my transitive dependency is declaring support dependency as `23+` – Eugen Martynov Feb 26 '16 at 06:37
  • 1
    A good idea could be to write the author of this library to avoid the use of + in the dependencies. It is exactly the reason why it should not be used. – Gabriele Mariotti Feb 26 '16 at 07:42

2 Answers2

1

Add the below line in to your build.gradle script.

androidTestCompile 'com.android.support:support-annotations:23.2.0'
Devendra Dagur
  • 840
  • 1
  • 14
  • 35
  • Why? I don't have instrumental tests – Eugen Martynov Feb 26 '16 at 06:18
  • Android studio just want to make sure that you test app and main app, both build with same versions of libraries. It is doesn't matter that you use your test app or not. – Devendra Dagur Feb 26 '16 at 06:24
  • @EugenMartynov If you find my answer helpful you can accept it. – Devendra Dagur Feb 26 '16 at 06:37
  • @EugenMartynov Actually You just posted only one line of your error, not complete code and also not posted your dependency file code. So I just answer your question as per your problem you posted here. – Devendra Dagur Feb 26 '16 at 06:42
  • I said on the topic that I didn't change gradle files. It is not direct information about my dependencies but gives you some insights. I'm four years on SO and first time I got such aggressive comments about accepting the answer even answer is not exact solution for my problem. Even I might not give complete information in question. We are here to help each other to find answers and not about getting points for accepted answers. Thank you for help! – Eugen Martynov Feb 26 '16 at 07:18
  • @EugenMartynov Sorry If my comment my comment hurt your feeling. My intention was not to post any aggressive comment. Yes, I also here to help each other but this is also true that, I also like to get point for answers. It is kind of motivation for me to post answer here. Higher points make me feel some kind of genius. Hahahahahahahahaahaha :) Its ok, If you don't find my answer correct for you. I'm glad that my answer help you. – Devendra Dagur Feb 26 '16 at 09:08
0

The cause is the dependency that we use. This library defines transitive dependency like:

<dependency>
      <groupId>com.android.support</groupId>
      <artifactId>appcompat-v7</artifactId>
      <version>23+</version>
      <scope>compile</scope>
</dependency>

So the solution was to exclude support library from it:

compile(<my dependency>, ext: 'aar') {
        exclude group: 'com.android.support'
        transitive = true
}

The owner of the library already notified about it.

Thank you for help!

Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114