android - 错误 :Conflict with dependency 'com.android.support:support-annotations' in project ':app'

标签 android gradle dependencies version

我试图解决这个 gradle 错误。我通过从我的一个 friend 那里得到它来导入这个项目。它在他的系统中完美地工作。好像我的 gradle 中有以下问题。

错误:与项目“:app”中的依赖项“com.android.support:support-annotations”冲突。应用程序 (27.0.2) 和测试应用程序 (25.4.0) 的已解决版本不同。

以下是我的gradle

Module app

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.2"
    defaultConfig {
        applicationId "com.startup.hospital"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:27.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:27.+'
    compile 'com.android.support:support-vector-drawable:27.0.2'
    compile 'com.android.support:support-v4:27.0.2'
    compile 'com.aurelhubert:ahbottomnavigation:2.1.0'
    compile 'com.github.arimorty:floatingsearchview:2.1.1'
    compile 'com.ss.bottomnavigation:bottomnavigation:1.5.2'
    compile 'jp.wasabeef:glide-transformations:2.0.2'


    compile 'junit:junit:4.12'
    androidTestCompile 'com.android.support.test:runner:1.0.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
}

Project gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.1"
    defaultConfig {
        applicationId "com.startup.hospital"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:27.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:27.+'
    compile 'com.android.support:support-vector-drawable:27.0.2'
    compile 'com.android.support:support-v4:27.0.2'
    compile 'com.aurelhubert:ahbottomnavigation:2.1.0'
    compile 'com.github.arimorty:floatingsearchview:2.1.1'
    compile 'com.ss.bottomnavigation:bottomnavigation:1.5.2'
    compile 'jp.wasabeef:glide-transformations:2.0.2'


    compile 'junit:junit:4.12'
    androidTestCompile 'com.android.support.test:runner:1.0.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
}

最佳答案

只需在您的 build.gradle (:app) 中添加以下内容

configurations.all {
    resolutionStrategy {
        force 'com.android.support:appcompat-v7:26.+'
        force 'com.android.support:support-compat:26.+'
        force 'com.android.support:support-core-ui:26.+'
        force 'com.android.support:support-annotations:26.+'
        force 'com.android.support:recyclerview-v7:26.+'
    }
}

关于android - 错误 :Conflict with dependency 'com.android.support:support-annotations' in project ':app' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47799189/

相关文章:

gradle - 在运行测试的同时获得jacoco代码覆盖率

java - Maven 不会下载外部项目所需的依赖项

android - 来自 Unity 应用程序的 WebSocket 连接

android - 在没有后端的 Android 应用程序中接收云端硬盘内容通知

android - 在android中实现一个带有分区的列表

java - 如何以编程方式设置具有透明背景颜色的按钮的不透明度

github - 使用gradle从 Artifactory 中检索SNAPSHOT jar的构建信息

android - gradle build 中没有测试任务

javascript - 连接 vendor js 文件的最佳方法是什么?

service - 准备就绪-在Pod启动时探测另一项服务