应用程序 (22.0.0) 和测试应用程序 (21.0.3) 的已解决版本不同 [英] Resolved versions for app (22.0.0) and test app (21.0.3) differ

查看:35
本文介绍了应用程序 (22.0.0) 和测试应用程序 (21.0.3) 的已解决版本不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到 API 22 并支持 lib 修订版 22 后,我收到以下警告:

After upgrading to API 22 and support lib revision 22 I'm getting the following warning:

警告:与依赖冲突'com.android.support:support-annotations'.应用程序的已解决版本(22.0.0) 和测试应用 (21.0.3) 不同.

Warning:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (22.0.0) and test app (21.0.3) differ.

Gradle 本身更宽容,但 Android Studio 没有那么多.

Gradle itself is more forgiving, but Android Studio, not so much.

我没有使用 21.0.3 声明的依赖项......是使用 21.0.3 的依赖库之一,而 Google 忘记用其余的批次更新它?

I have no dependencies declared with 21.0.3 ... is one of the dependent libraries using 21.0.3 and Google forgot to update it with the rest of the batch?

我的 build.gradle 剪掉了额外的东西

My build.gradle with the extras cut out

android {
  compileSdkVersion 22
  buildToolsVersion '22'

  defaultConfig {
    applicationId "com.REDACTED.android"
    minSdkVersion 14
    targetSdkVersion 22
    renderscriptSupportModeEnabled true
    versionName '1.0.0'
    versionCode 100
  }

  buildTypes {
    release {
      minifyEnabled true
      zipAlignEnabled true
      signingConfig signingConfigs.release
    }

    debug {
      minifyEnabled false
      zipAlignEnabled true
      signingConfig signingConfigs.debug
    }
  }

  dependencies {
    provided 'org.projectlombok:lombok:1.16.2'
    googleCompile 'com.google.android.gms:play-services-base:6.5.87'
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:support-v13:22.0.0'
    compile 'com.android.support:cardview-v7:22.0.0'
    compile 'com.android.support:palette-v7:22.0.0'
    compile 'com.android.support:support-annotations:22.0.0'
    compile 'com.github.chrisbanes.photoview:library:1.2.3'
    compile 'org.apache.commons:commons-lang3:3.3.2'
    compile 'commons-io:commons-io:2.4'
    compile 'commons-codec:commons-codec:1.10'
    compile 'com.jakewharton:butterknife:6.1.0'
    compile 'com.jakewharton:disklrucache:2.0.2'
    compile 'com.squareup:otto:1.3.6'
    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp:2.2.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
    compile 'com.squareup.okio:okio:1.2.0'
    compile 'com.flaviofaria:kenburnsview:1.0.6'
    compile 'com.edmodo:cropper:1.0.1'
    compile 'com.getbase:floatingactionbutton:1.8.0'
    compile 'com.nispok:snackbar:2.10.2'
    compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
    compile 'in.srain.cube:grid-view-with-header-footer:1.0.9'
    compile 'de.hdodenhof:circleimageview:1.2.2'
    compile fileTree(dir: 'libs', include: '*.jar')
    // Test Only Dependencies
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
    androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.0'
  }

更新:(感谢马克)

看起来像是 espresso-contrib

Looks like it's espresso-contrib

+--- com.android.support.test:testing-support-lib:0.1 (*)
--- com.android.support.test.espresso:espresso-contrib:2.0
     +--- com.android.support:recyclerview-v7:21.0.3
     |    +--- com.android.support:support-annotations:21.0.3
     |    --- com.android.support:support-v4:21.0.3
     |         --- com.android.support:support-annotations:21.0.3
     +--- com.android.support:support-v4:21.0.3 (*)
     --- com.android.support.test.espresso:espresso-core:2.0 (*)

推荐答案

处理这类事情的第一步是熟悉命令行 Gradle.

Step #1 when dealing with this sort of thing is to get comfortable with command-line Gradle.

第 2 步是运行 Gradle 依赖关系报告(例如,来自项目根目录的 gradle -q app:dependencies).这将提供问题更新中所示的 ASCII 树,它应该可以帮助您确定要求冲突的工件版本的内容.

Step #2 is to run the Gradle dependencies report (e.g., gradle -q app:dependencies from the project root). This will provide the ASCII tree as shown in the update to the question, and it should help you identify what is asking for the conflicting artifact versions.

第 3 步是决定需要更换什么.您选择仅替换冲突(support-annotations).就我个人而言,我会使用错误版本树 (recyclerview-v7) 的根,但据我所知,在这种情况下,这可能不是最佳做法.

Step #3 is to decide what needs replacing. You elected to replace just the conflict (support-annotations). Personally, I would have gone with the root of the wrong-version tree (recyclerview-v7), though for all I know that might not be the best course of action in this case.

第 4 步是添加 exclude 指令以阻止您在第 3 步中选择的内容:

Step #4 is to add the exclude directive to block what you chose in Step #3:

androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.0') {
    exclude module: 'support-annotations'
}

第 5 步是测试此更改的效果.你在做什么是说espresso-contrib 必须处理support-annotations的22.0.0版本.那可能会奏效.那可能不是.这取决于冲突的向后兼容性.在这种情况下,support-annotations 应该很不错.

Step #5 is to test the heck out of this change. What you are doing is saying that espresso-contrib has to deal with the 22.0.0 edition of support-annotations. That may work. That may not. It depends on the backwards compatibility of the conflict. In this case, support-annotations should be pretty good about it.

第 6 步是饮用您选择的饮料,一种适合您所在地区和一天中的时间的饮料.

Step #6 is to consume the beverage of your choice, one appropriate for your locale and time of day.

这篇关于应用程序 (22.0.0) 和测试应用程序 (21.0.3) 的已解决版本不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆