AndroidTests перестали собираться после добавления зависимости androidx.fragment:fragment-testing

После того, как я добавил зависимость fragment-testing в свой проект:

    // Testing dependencies
    espressoVersion = '3.2.0-beta01'
    testCoreVersion = '1.1.0'
    runnerVersion = '1.1.0'
    extJunitVersion = '1.1.0'
    testRulesVersion = '1.1.0'
    fragmentVersion = '1.1.0-alpha09'
    orchestratorVersion = '1.1.0'
    uiAutomatorVersion = '2.2.0'
    junitVersion = '4.12'
    mockitoVersion = '2.7.22'
    robolectricVersion = '4.2.1'
    liveDataTestingVersion = '1.1.0'
    androidArchCoreTestingVersion = '2.0.0'

androidTestImplementation("androidx.test.espresso:espresso-core:$rootProject.ext.espressoVersion")
androidTestImplementation "androidx.test:core:$rootProject.ext.testCoreVersion"
androidTestImplementation("androidx.test:runner:$rootProject.ext.runnerVersion")
androidTestImplementation "androidx.test.ext:junit:$rootProject.ext.extJunitVersion"
androidTestUtil ("androidx.test:orchestrator:$rootProject.ext.orchestratorVersion")
androidTestImplementation("androidx.test.espresso:espresso-intents:$rootProject.ext.espressoVersion")
implementation "androidx.test.espresso:espresso-idling-resource:$rootProject.ext.espressoVersion"
androidTestImplementation "androidx.test.uiautomator:uiautomator:$rootProject.ext.uiAutomatorVersion"
testImplementation "junit:junit:$rootProject.ext.junitVersion"
androidTestImplementation("androidx.test:rules:$rootProject.ext.testRulesVersion")
// required if you want to use Mockito for unit tests
testImplementation "org.mockito:mockito-core:$rootProject.ext.mockitoVersion"
// required if you want to use Mockito for Android tests
androidTestImplementation "org.mockito:mockito-android:$rootProject.ext.mockitoVersion"
testImplementation "org.robolectric:robolectric:$rootProject.ext.robolectricVersion"
testImplementation "org.robolectric:shadows-multidex:$rootProject.ext.robolectricVersion"
// LiveData Testing utility
testImplementation "com.jraska.livedata:testing:$rootProject.ext.liveDataTestingVersion"
testImplementation "androidx.arch.core:core-testing:$rootProject.ext.androidArchCoreTestingVersion"
// Once https://issuetracker.google.com/127986458 is fixed this can be testImplementation
implementation ("androidx.fragment:fragment-testing:$rootProject.ext.fragmentVersion")

когда я пытаюсь построить androidTests, это не удается:

ОШИБКА: сборка не удалась с исключением.

Что пошло не так: Не удалось определить зависимости задачи «:MyApp:mergeEsmartliveDebugAndroidTestResources».

Could not resolve all task dependencies for configuration ':MyApp:esmartliveDebugAndroidTestRuntimeClasspath'. Could not resolve androidx.test:core:1.1.0. Required by: project :MyApp project :MyApp > androidx.test.ext:junit:1.1.0 project :MyApp > androidx.fragment:fragment-testing:1.1.0-alpha09 Cannot find a version of 'androidx.test:core' that satisfies the version constraints: Dependency path 'MyApp:unspecified' --> 'androidx.test:core:1.1.0' Constraint path 'MyApp:unspecified' --> 'androidx.test:core:{strictly 1.1.0}' because of the following reason: esmartliveDebugRuntimeClasspath uses version 1.1.0 Dependency path 'MyApp:unspecified' --> 'androidx.test.ext:junit:1.1.0' --> 'androidx.test:core:1.1.0' Dependency path 'MyApp:unspecified' --> 'androidx.test.espresso:espresso-intents:3.2.0-beta01' --> 'androidx.test:core:1.2.0-beta01' Dependency path 'MyApp:unspecified' --> 'androidx.fragment:fragment-testing:1.1.0-alpha09' --> 'androidx.test:core:1.1.0'

Could not resolve androidx.test:core:{strictly 1.1.0}. Required by: project :MyApp Cannot find a version of 'androidx.test:core' that satisfies the version constraints: Dependency path 'MyApp:unspecified' --> 'androidx.test:core:1.1.0' Constraint path 'MyApp:unspecified' --> 'androidx.test:core:{strictly 1.1.0}' because of the following reason: esmartliveDebugRuntimeClasspath uses version 1.1.0 Dependency path 'MyApp:unspecified' --> 'androidx.test.ext:junit:1.1.0' --> 'androidx.test:core:1.1.0' Dependency path 'MyApp:unspecified' --> 'androidx.test.espresso:espresso-intents:3.2.0-beta01' --> 'androidx.test:core:1.2.0-beta01' Dependency path 'MyApp:unspecified' --> 'androidx.fragment:fragment-testing:1.1.0-alpha09' --> 'androidx.test:core:1.1.0'

Could not resolve androidx.test:monitor:1.1.1. Required by: project :MyApp > androidx.test.ext:junit:1.1.0 Cannot find a version of 'androidx.test:monitor' that satisfies the version constraints: Dependency path 'MyApp:unspecified' --> 'androidx.test.ext:junit:1.1.0' --> 'androidx.test:monitor:1.1.1' Dependency path 'MyApp:unspecified' --> 'androidx.test:runner:1.2.0-beta01' --> 'androidx.test:monitor:1.2.0-beta01' Dependency path 'MyApp:unspecified' --> 'androidx.test:core:1.2.0-beta01' --> 'androidx.test:monitor:1.2.0-beta01'

Could not resolve androidx.test:core:1.2.0-beta01. Required by: project :MyApp > androidx.test.espresso:espresso-intents:3.2.0-beta01 Cannot find a version of 'androidx.test:core' that satisfies the version constraints: Dependency path 'MyApp:unspecified' --> 'androidx.test:core:1.1.0' Constraint path 'MyApp:unspecified' --> 'androidx.test:core:{strictly 1.1.0}' because of the following reason: esmartliveDebugRuntimeClasspath uses version 1.1.0 Dependency path 'MyApp:unspecified' --> 'androidx.test.ext:junit:1.1.0' --> 'androidx.test:core:1.1.0' Dependency path 'MyApp:unspecified' --> 'androidx.test.espresso:espresso-intents:3.2.0-beta01' --> 'androidx.test:core:1.2.0-beta01' Dependency path 'MyApp:unspecified' --> 'androidx.fragment:fragment-testing:1.1.0-alpha09' --> 'androidx.test:core:1.1.0'

Could not resolve androidx.test:monitor:1.2.0-beta01. Required by: project :MyApp > androidx.test:runner:1.2.0-beta01 project :MyApp > androidx.test:core:1.2.0-beta01 Cannot find a version of 'androidx.test:monitor' that satisfies the version constraints: Dependency path 'MyApp:unspecified' --> 'androidx.test.ext:junit:1.1.0' --> 'androidx.test:monitor:1.1.1' Dependency path 'MyApp:unspecified' --> 'androidx.test:runner:1.2.0-beta01' --> 'androidx.test:monitor:1.2.0-beta01' Dependency path 'MyApp:unspecified' --> 'androidx.test:core:1.2.0-beta01' --> 'androidx.test:monitor:1.2.0-beta01'

Не уверен, как справиться с такого рода конфликтами... У кого-нибудь есть такая же проблема?

4
0
2 597
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Это быстрое решение:

implementation ("androidx.fragment:fragment-testing:1.1.0-beta01", {         
   exclude group: 'androidx.test', module: 'core'
})

Я получаю ошибку компиляции на gradle с этим. Действительно ли этот синтаксис правильный?

Rod 26.09.2019 01:35

@ Род, ты, наверное, можешь спросить здесь или здесь

Chisko 26.09.2019 06:19

Спасибо за добрый ответ Elroid. В итоге я тоже нашел правильный синтаксис. Теперь о рассматриваемой проблеме, включая это в gradle, мои модульные тесты фрагментов завершаются со следующей ошибкой: java.lang.NoClassDefFoundError: androidx/test/core/app/ActivityScenario$ActivityAction

Rod 26.09.2019 14:17

Как уже говорилось, это решение быстро. Если вам действительно нужен этот модуль, боюсь, вам придется найти другой ответ.

Chisko 26.09.2019 20:41

Каково решение?

IgorGanapolsky 17.01.2020 23:14

@IgorGanapolsky за исключением конфликтующего модуля core

Chisko 20.01.2020 18:38

Другие вопросы по теме