当前位置: 首页 > 知识库问答 >
问题:

应用程序(22.0.0)和测试应用程序(21.0.3)的解析版本不同

贾烨
2023-03-14

null

警告:与依赖项“com.android.support:support-annotations”冲突。应用程序(22.0.0)和测试应用程序(21.0.3)的解析版本不同。

Gradle本身更宽容,但Android工作室,就没那么宽容了。

我没有用21.0.3声明的依赖项...是不是其中一个依赖库使用21.0.3而谷歌忘了用批处理的其余部分更新它?

null

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'
  }

null

null

+--- 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 (*)

共有1个答案

习华灿
2023-03-14

在处理这类事情时,第一步是使用命令行Gradle。

步骤#2是运行Gradle dependencies报告(例如,来自项目根的Gradle-Q app:dependencies)。这将提供如问题更新中所示的ASCII树,它将帮助您识别冲突工件版本的要求。

第三步是决定需要替换什么。您选择只替换冲突(support-annotations)。就我个人而言,我会使用错误版本树(recyclerview-v7)的根,尽管据我所知,在这种情况下,这可能不是最佳的操作过程。

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

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

第5步是测试这个变化的真面目。您所做的是说espresso-contrib必须处理support-annotations22.0.0版。那也许管用。那可能不会。这取决于冲突的向后兼容性。在这种情况下,support-annotations应该很好。

第六步是喝你所选择的饮料,一种适合你的地点和时间的饮料。

 类似资料: