Reputation: 1006674
Given a project with this set of dependencies:
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"
}
I am getting the following error:
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.
How do I resolve this?
Upvotes: 3
Views: 2405
Reputation: 1006674
Artifact dependency inconsistencies are a common problem, and I expect this to be a frequent issue with the Architecture Components, given that the versioning of those components is byzantine1.
In this case, there is an undocumented version 1.0.2
of the undocumented android.arch.lifecycle:common
artifact.
android.arch.lifecycle:extensions:1.0.0-beta2
and android.arch.lifecycle:reactivestreams:1.0.0-beta2
depend upon this undocumented version 1.0.2
of the undocumented android.arch.lifecycle:common
artifact. However, the corresponding test artifact (android.arch.core:core-testing:1.0.0-beta2
) depends on version 1.0.0
of android.arch.lifecycle:common
. As a result, we get the conflict.
The workaround is to manually request 1.0.2
for the test code, via:
androidTestCompile 'android.arch.lifecycle:common:1.0.2'
Gradle will now use 1.0.2 for both the main code and the test code, and all is well.
1 The term "byzantine" is used to describe something that is unnecessarily complex. The Byzantines might have described complex things with the phrase "like the versioning system of the Architecture Components", had those components existed back then.
Upvotes: 2