如何解决android.arch.lifecycle:common版本冲突?

How Do I Resolve android.arch.lifecycle:common Version Conflicts?

给定一个具有这组依赖项的项目:

dependencies {
  compile "com.android.support:recyclerview-v7:26.1.0"
  compile "com.android.support:support-core-utils:26.1.0"
  compile "com.android.support:support-fragment:26.1.0"
  compile 'io.reactivex.rxjava2:rxjava:2.1.3'
  compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
  compile 'android.arch.lifecycle:runtime:1.0.0'
  compile 'android.arch.lifecycle:extensions:1.0.0-beta2'
  compile 'android.arch.lifecycle:reactivestreams:1.0.0-beta2'
  compile "android.arch.persistence.room:runtime:1.0.0-beta2"
  compile "android.arch.persistence.room:rxjava2:1.0.0-beta2"
  annotationProcessor "android.arch.persistence.room:compiler:1.0.0-beta2"
  androidTestCompile "com.android.support:support-annotations:26.1.0"
  androidTestCompile 'com.android.support.test:rules:0.5'
  androidTestCompile 'android.arch.core:core-testing:1.0.0-beta2'
  androidTestCompile "com.android.support:support-core-utils:26.1.0"
  androidTestCompile "com.android.support:support-compat:26.1.0"
}

我收到以下错误:

Error:Conflict with dependency 'android.arch.lifecycle:common' in project ':app'. Resolved versions for app (1.0.2) and test app (1.0.0) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

我该如何解决这个问题?

工件依赖性不一致是一个常见问题,我预计这将是架构组件的一个常见问题,因为这些组件的版本控制是拜占庭1

在这种情况下,存在未记录的 android.arch.lifecycle:common 工件的未记录版本 1.0.2

android.arch.lifecycle:extensions:1.0.0-beta2android.arch.lifecycle:reactivestreams:1.0.0-beta2 取决于未记录的 android.arch.lifecycle:common 工件的未记录版本 1.0.2。但是,相应的测试工件 (android.arch.core:core-testing:1.0.0-beta2) 取决于 android.arch.lifecycle:common 的版本 1.0.0。结果,我们得到了冲突。

解决方法是手动请求 1.0.2 测试代码,通过:

androidTestCompile 'android.arch.lifecycle:common:1.0.2'

Gradle 现在主要代码和测试代码都使用 1.0.2,一切正常。


1 The term "byzantine" is used to describe something that is unnecessarily complex. The Byzantines 可能会用短语 "like the versioning system of the Architecture Components" 描述复杂的事物,如果当时存在这些组件的话。