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

This is the error i am getting while building the app. Below is my build.gradle file.

    apply plugin: 'com.android.application'

    android {
           compileSdkVersion 25
           buildToolsVersion "25.0.2"
           defaultConfig {
                          applicationId "com.example.sanket.loginapp"
                          minSdkVersion 18
                          targetSdkVersion 25
                          versionCode 1
                          versionName "1.0"
                          testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
      }
   }

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
    exclude module: 'support-annotations'
}
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2')
        {
            exclude module: 'support-annotations'
            exclude module: 'support-v4'
            exclude module: 'support-v13'
            exclude module: 'recyclerview-v7'
            exclude module: 'appcompat-v7'
        }
androidTestCompile('com.android.support.test.espresso:espresso-web:2.2.2')
        {
            exclude module: 'support-annotations'
        }
androidTestCompile ('com.android.support.test.espresso:espresso-intents:2.2.2') {
   exclude module: 'support-annotations'
}
androidTestCompile ('com.android.support.test.uiautomator:uiautomator-v18:2.1.2'){
    exclude module: 'support-annotations'
}
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
}

this is my build.gradle file. I have tried plenty of answers provided in the forum. nothing seems to be working. can someone help me out with it ?

2 Answers2

0

update your androidtestcompile with addition of this line:

 androidTestCompile 'com.android.support:support-annotations:25.1.0'

or try with excluding support-library for all espresso modules like this:

androidTestCompile ('com.android.support.test:runner:0.5') {
    exclude group: 'com.android.support'
}
Pushpendra
  • 2,791
  • 4
  • 26
  • 49
0

Refer to

Resolved versions for app (22.0.0) and test app (21.0.3) differ

https://blog.mindorks.com/avoiding-conflicts-in-android-gradle-dependencies-28e4200ca235#.hih8d864v

You can use

./gradlew dependencies

to chek dependencies tree.

And you will see that the problem is in

com.android.support.test:runner:0.5 
com.android.support.test:rules:0.5
com.android.support.test:rules:0.5

which have lower version of support-anotations.

So, just exclude it in that modules:

androidTestCompile ('com.android.support.test:runner:0.5') {
        exclude module: 'support-annotations'
}
androidTestCompile ('com.android.support.test:rules:0.5') {
    exclude module: 'support-annotations'
}
androidTestCompile ('com.android.support.test:rules:0.5') {
    exclude module: 'support-annotations'
}
Community
  • 1
  • 1
adalpari
  • 3,052
  • 20
  • 39
  • hey, this is also not working. really don't know what is going on with this one. for other application this fix worked. but for this, it is not working – sanketprabhune Jan 11 '17 at 14:14