与依赖冲突:build.gradle

时间:2018-05-20 16:35:56

标签: java android 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'

}

a screenshot on the error message

谢谢。

2 个答案:

答案 0 :(得分:0)

将此作为最高级别用于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 {
    ........
    .......
}

答案 1 :(得分:0)

添加android测试依赖

http.createServer(app)

并用实现替换compile

androidTestImplementation 'com.android.support:support-annotations:27.1.1'

因为编译配置现已弃用,应该由implementation或api替换,以获取有关read this answer的更多信息