Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ

后端 未结 9 1241
臣服心动
臣服心动 2020-11-28 21:38

When building I get the following error:

Conflict with dependency \'com.android.support:support-annotations\'. Resolved versions for app (23.1.0) and test a         


        
9条回答
  •  清酒与你
    2020-11-28 22:29

    Source: CodePath - UI Testing With Espresso

    1. Finally, we need to pull in the Espresso dependencies and set the test runner in our app build.gradle:
    // build.gradle
    ...
    android {
        ...
        defaultConfig {
            ...
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
    }
    
    dependencies {
        ...
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
            // Necessary if your app targets Marshmallow (since Espresso
            // hasn't moved to Marshmallow yet)
            exclude group: 'com.android.support', module: 'support-annotations'
        }
        androidTestCompile('com.android.support.test:runner:0.5') {
            // Necessary if your app targets Marshmallow (since the test runner
            // hasn't moved to Marshmallow yet)
            exclude group: 'com.android.support', module: 'support-annotations'
        }
    }
    

    I've added that to my gradle file and the warning disappeared.

    Also, if you get any other dependency listed as conflicting, such as support-annotations, try excluding it too from the androidTestCompile dependencies.

提交回复
热议问题