【问题标题】:Conflict with dependency 'com.android.support:support-media-compat' in project ':app'与项目“:app”中的依赖项“com.android.support:support-media-compat”冲突
【发布时间】:2018-08-30 10:11:53
【问题描述】:

当我尝试开始测试时出现此错误:

与项目 ':app' 中的依赖项 'com.android.support:support-media-compat' 冲突。应用程序 (27.0.0) 和测试应用程序 (27.1.1) 的已解决版本不同。详情请见https://d.android.com/r/tools/test-apk-dependency-conflicts.html。

这是我的 build.gradle 依赖项:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'

    // ViewModel and LiveData
    implementation "android.arch.lifecycle:extensions:1.1.1"
    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
    // ButterKnife Library
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    // Gson Library
    implementation 'com.google.code.gson:gson:2.8.5'
    // Glide Library
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
    // ExoPlayer Library
    implementation 'com.google.android.exoplayer:exoplayer-core:2.8.3'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.8.3'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation "com.android.support.test:rules:1.0.2"
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support:support-annotations:27.1.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
}

我没有看到在我的代码中的任何地方使用 27.0.0 版本,我认为 ExoPlayer 可能在内部使用该版本!我能做些什么来解决冲突?!

【问题讨论】:

    标签: java android unit-testing testing


    【解决方案1】:

    在你的 gradle 文件中使用依赖

    实现'com.android.support:support-media-compat:27.1.1'

    【讨论】:

    • 这解决了我的问题,非常感谢。我认为 ExoPlayer 使用的是版本为 27.0.0 的版本,并且通过显式添加依赖项意味着我正在覆盖库正在使用的内容,对吧?
    【解决方案2】:

    尝试使用 //无检查 GradleCompatible 上面显示错误的行

    【讨论】:

      猜你喜欢
      • 2018-11-20
      • 1970-01-01
      • 2019-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-12
      • 1970-01-01
      • 2021-11-05
      相关资源
      最近更新 更多