首页 > 解决方案 > 与依赖冲突:build.gradle

问题描述

我添加了一个新的依赖项

compile 'com.github.markomilos:paginate:0.5.1'

但是在同步构建之后,我有一个错误

“与依赖项 com.android.support:support-annotations' 冲突”

这是我的 build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.formation.mvpnewproject"
        minSdkVersion 17
        targetSdkVersion 26
        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.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.google.code.gson:gson:2.8.1'

    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'

    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.3.0'
    compile 'com.github.markomilos:paginate:0.5.1'

}

错误消息的屏幕截图

谢谢你。

标签: javaandroidgradle

解决方案


build.gradle(app)将此作为顶级文件使用到您的文件中。

configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:23.0.1'
}

喜欢:

apply plugin: 'com.android.application'

android {
    .......
    .......
}

configurations.all {
     resolutionStrategy.force 'com.android.support:support-annotations:23.0.1'
}

dependencies {
    ........
    .......
}

推荐阅读