我在构建android项目时遇到冲突依赖性错误

我在构建android项目时遇到冲突依赖性错误,android,ui-automation,Android,Ui Automation,这是我在构建应用程序时遇到的错误。下面是我的build.gradle文件 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. 这是我的build.grad

这是我在构建应用程序时遇到的错误。下面是我的build.gradle文件

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.

这是我的build.gradle文件。我尝试了论坛上提供的很多答案。似乎什么都没用。有人能帮我一下吗?

添加这一行更新您的
androidtestcompile

    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'
}
或者尝试排除所有
espresso
模块的
support library
,如下所示:

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

你可以用

androidTestCompile ('com.android.support.test:runner:0.5') {
    exclude group: 'com.android.support'
}
检查依赖关系树

你会发现问题就在这里

./gradlew dependencies
具有较低版本的支持站

因此,只需将其排除在该模块中:

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

嘿,这也不行。我真的不知道这是怎么回事。对于其他应用程序,此修复程序有效。但对于这一点,这是行不通的
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'
}