当前位置: 首页 > 知识库问答 >
问题:

与项目“:App”中的依赖项“com.android.support:support-annotations”冲突。应用程序和测试应用程序的解析版本不同

权浩邈
2023-03-14

今天我在android工作室开始了一个新的项目。一切顺利,没有差错。添加项目后,我借助android Studio中的Firebase助手工具,将项目与Firebase实时数据库进行了连接。

然后我得到这个错误:

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.

我看到错误主要来自于在我的应用程序级别build.gradle文件的末尾添加了这一行。因为当我把它评论出来的时候,它构建的很好。

apply plugin: 'com.google.gms.google-services'
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'

我的项目:build.gradle:

// 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
}

共有1个答案

张砚
2023-03-14

试试看:

 androidTestCompile ("com.android.support.test.espresso:espresso-core:3.0.1") {
      exclude group: 'com.android.support', module: 'support-annotations'
 }

请查看此链接以获得更好的理解

 类似资料: