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文件。
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'
}
这是我的build.gradle文件。我在论坛中尝试了很多答案。似乎什么都没有用。有人可以帮助我吗?
答案 0 :(得分:0)
通过添加此行来更新androidtestcompile
:
androidTestCompile 'com.android.support:support-annotations:25.1.0'
或尝试将support-library
排除在所有espresso
模块之后:
androidTestCompile ('com.android.support.test:runner:0.5') {
exclude group: 'com.android.support'
}
答案 1 :(得分:0)
参阅
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
您可以使用
./gradlew dependencies
to chek dependencies tree。
你会看到问题出在
com.android.support.test:runner:0.5
com.android.support.test:rules:0.5
com.android.support.test:rules:0.5
具有较低版本的 support-anotations 。
所以,只需在那些模块中排除它:
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'
}