Reputation: 8371
I have these gradle dependencies for all my instrumentation tests:
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.1.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.1.0'
implementation 'androidx.test.espresso:espresso-idling-resource:3.1.0'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
debugImplementation 'androidx.fragment:fragment-testing:1.2.0-alpha01'
implementation 'androidx.fragment:fragment:1.1.0-alpha01'
androidTestImplementation 'org.mockito:mockito-android:2.24.5'
Once i update them to:
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.2.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.2.0'
implementation 'androidx.test.espresso:espresso-idling-resource:3.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
debugImplementation 'androidx.fragment:fragment-testing:1.2.0-alpha01'
implementation 'androidx.fragment:fragment:1.2.0-alpha01'
androidTestImplementation 'org.mockito:mockito-android:2.24.5'
And run the test, I get the following error:
Cannot find a version of 'androidx.test:core' that satisfies the version constraints:
Dependency path 'my_package_name:app:unspecified' --> 'androidx.test.espresso:espresso-intents:3.2.0' --> 'androidx.test:core:1.2.0'
.... and so one with lots of lines
How do I resolve this? Why does it happen?
Upvotes: 2
Views: 2075
Reputation: 1454
Why this happens?
This happens because of a version conflict for androidx.test:core:1.2.0
:
Dependency androidx.test.espresso:espresso-intents:3.2.0
uses version 1.2.0 of the core library. While there is another dependency that uses another version of the same library, and that makes Gradle unhappy. If you keep reading through those lots of lines you will see what this another dependency is but I highly suspect it is androidx.fragment:fragment-testing:1.2.0-alpha01
which depends on version 1.1.1 of the core library.
How to resolve this:
Given you really need to upgrade your espresso, and assuming that the problematic library is fragment-testing, a simple workaround would be to change
debugImplementation 'androidx.fragment:fragment-testing:1.2.0-alpha01'
to
debugImplementation ("androidx.fragment:fragment-testing:1.2.0-alpha01", {exclude group: 'androidx.test', module: 'core' })
Upvotes: 4