简体   繁体   English

测试 WorkManager 时无法解析 com.google.guava:listenablefuture:{strictly 1.0}

[英]Could not resolve com.google.guava:listenablefuture:{strictly 1.0} when testing WorkManager

I have an app that uses WorkManager for some scheduled tasks, and I'm testing it with the aid of a bunch of different frameworks.我有一个应用程序,它使用 WorkManager 执行一些计划任务,我正在一堆不同框架的帮助下对其进行测试。 It seems relevant to this issue that I'm using robolectric and of course androidx.work:work-testing .我正在使用 robolectric 和 androidx.work:work-testing 这似乎与这个问题有关。

I'm able to run unit tests successfully, but when I attempt to run instrumentation tests, Calculate task graph fails with我能够成功运行单元测试,但是当我尝试运行检测测试时, 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'

Tried adding guava "com.google.guava:guava:27.0.1-android" (against my will) as a testImplementation and an androidTestImplementation and got a 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' instead of the line 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'

Some dependencies in my module's build.gradle:我模块的 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"

for me, there was same error between Truth and androidx.work:work-runtime对我来说,Truth 和 androidx.work:work-runtime 之间存在同样的错误

and fixed with the below并用下面的固定

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

for robolectric用于机器人电子

androidTestImplementation "org.robolectric:robolectric:4.2.1", { exclude group: 'com.google.guava', module:'listenablefuture'}
api 'com.google.guava:listenablefuture:1.0'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法解析 com.google.guava:guava:30.1-jre - Gradle 项目同步失败。 基本功能将无法正常工作 - 在 kotlin 项目中 - Could not resolve com.google.guava:guava:30.1-jre - Gradle project sync failed. Basic functionality will not work properly - in kotlin project 错误:无法找到:com.google.guava:guava:18.0。+ - Error:Failed to find: com.google.guava:guava:18.0.+ 使用最新的番石榴库实现 CacheBuilder 时出错(实现 'com.google.guava:guava:28.2-jre) - Error when implementing CacheBuilder using latest guava library (implementation 'com.google.guava:guava:28.2-jre) java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.toImmutableSet() 即使使用“com.google.guava:guava:24.0-android” - java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.toImmutableSet() even with 'com.google.guava:guava:24.0-android' 错误:在项目':app'中与依赖项'com.google.guava:guava'发生冲突。 应用(18.0)和测试应用(16.0.1)的已解决版本不同 - Error:Conflict with dependency 'com.google.guava:guava' in project ':app'. Resolved versions for app (18.0) and test app (16.0.1) differ 无法解析':app @ debug / compileClasspath'的依赖项:gradle同步时无法解决com.google.android.things:androidthings:1.0错误 - Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.things:androidthings:1.0 error while gradle sync 添加 Android WorkManager 时已存在用于 ListenableFuture 的程序类型 - Program type already present for ListenableFuture when adding Android WorkManager 无法解决:com.google.android.material.material:1.0 - Failed to resolve: com.google.android.material.material:1.0 无法解析 com.google.gms:google-services:3.0.0 - Could not resolve com.google.gms:google-services:3.0.0 无法解析 com.google.gms:google-services:4.3.3 - Could not resolve com.google.gms:google-services:4.3.3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM