У меня есть эти зависимости для всех моих инструментальных тестов:
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'
Как только я обновлю их до:
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'
И запустив тест, я получаю следующую ошибку:
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'
.... и так один с большим количеством строк
Как решить эту проблему? Почему это происходит?
Почему это происходит?
Это происходит из-за конфликта версий для androidx.test:core:1.2.0
:
Зависимость androidx.test.espresso:espresso-intents:3.2.0
использует версию 1.2.0 основной библиотеки. В то время как есть другая зависимость, которая использует другую версию той же библиотеки, и это делает Gradle недовольным. Если вы продолжите читать эти много линий, вы увидите, что это за другая зависимость, но я очень подозреваю, что это androidx.fragment:fragment-testing:1.2.0-alpha01
, который зависит от версии 1.1.1 базовой библиотеки.
Как это решить:
Учитывая, что вам действительно нужно обновить свой эспрессо, и предполагая, что проблемная библиотека тестирует фрагменты, простым обходным путем было бы изменить
debugImplementation 'androidx.fragment:fragment-testing:1.2.0-alpha01'
к
debugImplementation ("androidx.fragment:fragment-testing:1.2.0-alpha01", {exclude group: 'androidx.test', module: 'core' })