gpt4 book ai didi

android - 测试 WorkManager 时无法解析 com.google.guava :listenablefuture:{strictly 1. 0}

转载 作者:行者123 更新时间:2023-12-03 21:31:24 31 4
gpt4 key购买 nike

我有一个使用 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'

尝试添加 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"

最佳答案

对我来说,Truth 和 androidx.work:work-runtime 之间存在相同的错误

并用以下固定

androidTestImplementation 'com.google.truth:truth:1.0.1', { exclude group: 'com.google.guava', module:'listenablefuture'}
api 'com.google.guava:listenablefuture:1.0'

用于机器人电动
androidTestImplementation "org.robolectric:robolectric:4.2.1", { exclude group: 'com.google.guava', module:'listenablefuture'}
api 'com.google.guava:listenablefuture:1.0'

关于android - 测试 WorkManager 时无法解析 com.google.guava :listenablefuture:{strictly 1. 0},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56640258/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com