У меня есть приложение, которое использует WorkManager для некоторых запланированных задач, и я тестирую его с помощью множества различных фреймворков.Похоже, что уместно в этом вопросе, что я использую robolectric и, конечно, androidx.work:work-testing.
Я могу успешно запустить модульные тесты, но когда я пытаюсь запустить инструментальные тесты, Calculate task graph
завершается неудачно с
Could not determine the dependencies of task ':myModule:mergeDebugAndroidTestResources'.
> Could not resolve all task dependencies for configuration ':myModule:debugAndroidTestRuntimeClasspath'.
> Could not resolve com.google.guava:listenablefuture:{strictly 1.0}.
Required by:
project :myModule
> Cannot find a version of 'com.google.guava:listenablefuture' that satisfies the version constraints:
Dependency path 'MyApp:myModule:unspecified' --> 'androidx.work:work-testing:2.0.1' --> 'androidx.work:work-runtime:2.0.1' --> 'com.google.guava:listenablefuture:1.0'
Constraint path 'MyApp:myModule:unspecified' --> 'com.google.guava:listenablefuture:{strictly 1.0}' because of the following reason: debugRuntimeClasspath uses version 1.0
Dependency path 'MyApp:myModule:unspecified' --> 'org.robolectric:robolectric:4.2.1' --> 'org.robolectric:resources:4.2.1' --> 'com.google.guava:guava:27.0.1-jre' --> 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
> Could not resolve com.google.guava:listenablefuture:1.0.
Required by:
project :myModule > androidx.work:work-runtime:2.0.1
> Cannot find a version of 'com.google.guava:listenablefuture' that satisfies the version constraints:
Dependency path 'MyApp:myModule:unspecified' --> 'androidx.work:work-testing:2.0.1' --> 'androidx.work:work-runtime:2.0.1' --> 'com.google.guava:listenablefuture:1.0'
Constraint path 'MyApp:myModule:unspecified' --> 'com.google.guava:listenablefuture:{strictly 1.0}' because of the following reason: debugRuntimeClasspath uses version 1.0
Dependency path 'MyApp:myModule:unspecified' --> 'org.robolectric:robolectric:4.2.1' --> 'org.robolectric:resources:4.2.1' --> 'com.google.guava:guava:27.0.1-jre' --> 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
> Could not resolve com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava.
Required by:
project :myModule > org.robolectric:robolectric:4.2.1 > org.robolectric:resources:4.2.1 > com.google.guava:guava:27.0.1-jre
> Cannot find a version of 'com.google.guava:listenablefuture' that satisfies the version constraints:
Dependency path 'MyApp:myModule:unspecified' --> 'androidx.work:work-testing:2.0.1' --> 'androidx.work:work-runtime:2.0.1' --> 'com.google.guava:listenablefuture:1.0'
Constraint path 'MyApp:myModule:unspecified' --> 'com.google.guava:listenablefuture:{strictly 1.0}' because of the following reason: debugRuntimeClasspath uses version 1.0
Dependency path 'MyApp:myModule:unspecified' --> 'org.robolectric:robolectric:4.2.1' --> 'org.robolectric:resources:4.2.1' --> 'com.google.guava:guava:27.0.1-jre' --> 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
Попытка добавления гуавы "com.google.guava:guava:27.0.1-android"
(против моей воли)в качестве testImplementation и androidTestImplementation и получил Dependency path 'MyApp:mymodule:unspecified' --> 'com.google.guava:guava:27.0.1-jre' --> 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
вместо строки Dependency path 'MyApp:myModule:unspecified' --> 'org.robolectric:robolectric:4.2.1' --> 'org.robolectric:resources:4.2.1' --> 'com.google.guava:guava:27.0.1-jre' --> 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
Некоторые зависимости в build.gradle моего модуля:
implementation "androidx.work:work-runtime-ktx:2.0.1"
testImplementation "org.robolectric:robolectric:4.2.1"
androidTestImplementation "org.robolectric:robolectric:4.2.1"
androidTestImplementation "androidx.work:work-testing:2.0.1"
androidTestImplementation "androidx.work:work-testing:2.0.1"