Resolved versions for app (22.0.0) and test app (21.0.3) differ

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

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.

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.

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

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.

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

Leave a Comment