Could not resolve com.google.guava:listenablefuture:{strictly 1.0} when testing WorkManager
Asked Answered
H

1

6

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. It seems relevant to this issue that I'm using robolectric and of course 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

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'

Some dependencies in my module's 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"
Hallie answered 18/6, 2019 at 0:14 Comment(1)
facing same issue. Trying to use the latest androidX stuff in alpha. not sure what broke when my code hasnt changed and i dont use + in gradle dependenciesCleareyed
C
0

for me, there was same error between Truth and 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'
Chronograph answered 11/2, 2020 at 9:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.