Android 与依赖冲突';support:supportannotations';在项目&x27;中:应用程序&x27;。应用程序和测试应用程序的解析版本不同
今天我在安卓工作室开始了一个新项目。一切顺利,没有差错。添加项目后,我在android studio中借助Firebase助手工具将项目与Firebase实时数据库连接 然后我得到这个错误:Android 与依赖冲突';support:supportannotations';在项目&x27;中:应用程序&x27;。应用程序和测试应用程序的解析版本不同,android,firebase,android-gradle-plugin,google-play-services,build.gradle,Android,Firebase,Android Gradle Plugin,Google Play Services,Build.gradle,今天我在安卓工作室开始了一个新项目。一切顺利,没有差错。添加项目后,我在android studio中借助Firebase助手工具将项目与Firebase实时数据库连接 然后我得到这个错误: Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependency 'com.android.support:support-annotations' in project ':app'
Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (23.0.0) and test app (25.4.0) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
我发现错误主要来自于在我的app levelbuild.gradle
文件末尾添加这一行。因为当我把它注释掉时,它构建得很好
apply plugin: 'com.google.gms.google-services'
我对gradle建筑系统知之甚少。仅连接到firebase并添加firebase数据库依赖项会有什么问题
我需要检查的资源
我的应用程序:build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.learning.insanes.chothavandar"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// implementation 'com.google.firebase:firebase-database:11.6.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我的项目:build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.learning.insanes.chothavandar"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// implementation 'com.google.firebase:firebase-database:11.6.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
试试这个:
androidTestCompile ("com.android.support.test.espresso:espresso-core:3.0.1") {
exclude group: 'com.android.support', module: 'support-annotations'
}
为了更好地理解应用程序中的,请查看此项:依赖项中的build.gradle文件添加以下行,或者如果已经存在,则将其更改为: 依赖关系{ .. 实现'com.android.support:appcompat-v7:25.4.0' ..
}请详细说明您的答案。我应该把这个放在哪里?我的问题到底是什么?它将如何帮助解决我的问题?在你的应用程序build.gradle中有一行代码
androidTestImplementation'com.android.support.test.espresso:espresso core:3.0.1'
。把它换成我贴的那个。它将排除报告的库模块。出现此错误是因为您试图编译同一库的两个不同版本。阅读我建议的链接以更好地理解您的问题谢谢。你的解决方案有效。如果您还有test:runner
作为测试依赖项,请记住添加:androidTestImplementation(“com.android.support.test:runner:1.0.1”){排除组:“com.android.support”,模块:“support annotations”}