Comments (10)
Thanks for the reproduced @MyDogTom. I was finally able to track down the issue and fix it in 494bd46.
I don't know though, why upgrading ExoPlayer fixed it and why it exists in the first place. It must be related to in which order Gradle does things and this might also be a "bug" in Gradle itself (I am not sure).
Thanks again for reporting this and your patience. I will release a 31.1.1
version of the plugin with the fix.
from missing-metadata-guava.
Sorry, I was mistaken. I forgot that the plugin actually adds the conflict resolution rules already. So it should just work and there should be no need to add resolution rules for capability conflicts.
I tried to reproduce your issue and added a test with the Android plugin, but had no success. Would you be able to share a reproducer?
from missing-metadata-guava.
Hi @MyDogTom. The plugin is adding the com.google.guava:listenablefuture
capability to Guava, because Guava contains that feature directly nowadays. And it removes a "hack" Guava is doing to upgrade to an empty listenablefuture.jar
with version 9999.0-empty-to-avoid-conflict-with-guava
so that you do not get that empty file on your classpath.
If you have something else depending on listenablefuture
directly - e.g. androidx.concurrent:concurrent-futures
- you will get a conflict (which you are seeing).
You need to add a resolution strategy for the capability to resolve the conflict:
configurations.all {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.guava:listenablefuture") {
selectHighestVersion()
}
}
from missing-metadata-guava.
Thanks for your help!
I tried your snippet, but still received an error.
Could not determine the dependencies of task ':settings:mergeDebugUnitTestResources'.
> Could not resolve all task dependencies for configuration ':settings:debugUnitTestRuntimeClasspath'.
> Could not resolve com.google.guava:guava:27.0.1-jre.
Required by:
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:resources:4.7.2
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:sandbox:4.7.2
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:utils:4.7.2
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:plugins-maven-dependency-resolver:4.7.2
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:shadows-framework:4.7.2 > org.robolectric:nativeruntime:4.7.2
> Module 'com.google.guava:guava' has been rejected:
Cannot select module with conflict on capability 'com.google.guava:listenablefuture:1.0' also provided by [com.google.guava:listenablefuture:1.0(runtime), com.google.guava:guava:27.0.1-jre(androidRuntime)]
> Could not resolve com.google.guava:listenablefuture:1.0.
Required by:
project :settings > project :base_ui > androidx.work:work-runtime:2.5.0
project :settings > project :navigation > androidx.browser:browser:1.3.0
project :settings > project :navigation > androidx.browser:browser:1.3.0 > androidx.concurrent:concurrent-futures:1.0.0
> Module 'com.google.guava:listenablefuture' has been rejected:
Cannot select module with conflict on capability 'com.google.guava:listenablefuture:1.0' also provided by [com.google.guava:guava:27.0.1-jre(androidRuntime), com.google.guava:guava:27.1-android(runtime)]
> Could not resolve com.google.guava:guava:27.1-android.
Required by:
project :settings > project :base-api > com.google.android.exoplayer:exoplayer:2.13.0 > com.google.android.exoplayer:exoplayer-core:2.13.0 > com.google.android.exoplayer:exoplayer-common:2.13.0
> Module 'com.google.guava:guava' has been rejected:
Cannot select module with conflict on capability 'com.google.guava:listenablefuture:1.0' also provided by [com.google.guava:listenablefuture:1.0(runtime), com.google.guava:guava:27.0.1-jre(androidRuntime)]
Then I thought that probably selectHighestVersion()
is not able to choose between com.google.guava:listenablefuture:1.0
, com.google.guava:guava:27.0.1-jre
and com.google.guava:guava:27.1-android
. I received these three by printing candidate.id.displayName
.
Based on that assumption I excluded com.google.guava:listenablefuture:1.0
from resolution to ensure that it's never selected.
configuration.resolutionStrategy.capabilitiesResolution
.withCapability("com.google.guava:listenablefuture") { resolution ->
val onlyGuava = resolution.candidates.filter {
it.id.displayName.startsWith("com.google.guava:guava")
}
val selected = onlyGuava.maxByOrNull {
VersionNumber.parse(it.id.displayName.substringAfterLast(":"))
}
selected?.let {
resolution.select(it)
} ?: throw IllegalStateException("can't find resolution")
}
this time the error was different
Could not determine the dependencies of task ':settings:mergeDebugUnitTestResources'.
> Could not resolve all task dependencies for configuration ':settings:debugUnitTestRuntimeClasspath'.
> Could not resolve com.google.guava:guava:27.0.1-jre.
Required by:
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:resources:4.7.2
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:sandbox:4.7.2
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:utils:4.7.2
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:plugins-maven-dependency-resolver:4.7.2
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:shadows-framework:4.7.2 > org.robolectric:nativeruntime:4.7.2
> Module 'com.google.guava:guava' has been rejected:
Cannot select module with conflict on capability 'com.google.collections:google-collections:27.1' also provided by [com.google.guava:guava:27.0.1-jre(androidRuntime)]
> Could not resolve com.google.guava:listenablefuture:1.0.
Required by:
project :settings > project :base_ui > androidx.work:work-runtime:2.5.0
project :settings > project :navigation > androidx.browser:browser:1.3.0
project :settings > project :navigation > androidx.browser:browser:1.3.0 > androidx.concurrent:concurrent-futures:1.0.0
> Module 'com.google.guava:guava' has been rejected:
Cannot select module with conflict on capability 'com.google.collections:google-collections:27.1' also provided by [com.google.guava:guava:27.0.1-jre(androidRuntime)]
> Could not resolve com.google.guava:guava:27.1-android.
Required by:
project :settings > project :base-api > com.google.android.exoplayer:exoplayer:2.13.0 > com.google.android.exoplayer:exoplayer-core:2.13.0 > com.google.android.exoplayer:exoplayer-common:2.13.0
> Module 'com.google.guava:guava' has been rejected:
Cannot select module with conflict on capability 'com.google.collections:google-collections:27.1' also provided by [com.google.guava:guava:27.0.1-jre(androidRuntime)]
Then I added resolution for com.google.collections:google-collections
and com.google.guava:guava
(next error I received) using selectHighestVersion
.
configuration.resolutionStrategy
.capabilitiesResolution
.withCapability("com.google.collections:google-collections") { resolution ->
resolution.selectHighestVersion()
}
configuration.resolutionStrategy
.capabilitiesResolution
.withCapability("com.google.guava:guava") { resolution ->
resolution.selectHighestVersion()
}
This time compilation succeeded.
To be honest the final result looks a bit overcomplicated, but I guess it's the way to go, right?
from missing-metadata-guava.
That you also need to do com.google.collections:google-collections
makes sense. But you should not need to do something for com.google.guava:guava
. Also, the more complicated resolution you did should not be necessary - selectHighestVersion()
should be enough.
com.google.guava:guava:27.0.1-jre
and com.google.guava:guava:27.1-android
should usually not turn up in the capability conflict. They are the same module (only with different versions).
Maybe there is indeed an issue with the plugin. I will try to reproduce the problem.
Which Gradle and Android versions are you using?
from missing-metadata-guava.
Gradle 7.3.3 and AGP 7.0.4.
from missing-metadata-guava.
But you should not need to do something for com.google.guava:guava.
btw, If I don't include resolution for com.google.guava:guava
then I see the following error
> Could not resolve all task dependencies for configuration ':settings:debugUnitTestRuntimeClasspath'.
> Could not resolve com.google.guava:guava:27.0.1-jre.
Required by:
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:resources:4.7.2
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:sandbox:4.7.2
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:utils:4.7.2
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:plugins-maven-dependency-resolver:4.7.2
project :settings > org.robolectric:robolectric:4.7.2 > org.robolectric:shadows-framework:4.7.2 > org.robolectric:nativeruntime:4.7.2
> Module 'com.google.guava:guava' has been rejected:
Cannot select module with conflict on capability 'com.google.guava:guava:27.1-android' also provided by [com.google.guava:guava:27.0.1-jre(androidRuntime)]
> Could not resolve com.google.guava:listenablefuture:1.0.
Required by:
project :settings > project :base_ui > androidx.work:work-runtime:2.5.0
project :settings > project :navigation > androidx.browser:browser:1.3.0
project :settings > project :navigation > androidx.browser:browser:1.3.0 > androidx.concurrent:concurrent-futures:1.0.0
> Module 'com.google.guava:guava' has been rejected:
Cannot select module with conflict on capability 'com.google.guava:guava:27.1-android' also provided by [com.google.guava:guava:27.0.1-jre(androidRuntime)]
> Could not resolve com.google.guava:guava:27.1-android.
Required by:
project :settings > project :base-api > com.google.android.exoplayer:exoplayer:2.13.0 > com.google.android.exoplayer:exoplayer-core:2.13.0 > com.google.android.exoplayer:exoplayer-common:2.13.0
> Module 'com.google.guava:guava' has been rejected:
Cannot select module with conflict on capability 'com.google.guava:guava:27.1-android' also provided by [com.google.guava:guava:27.0.1-jre(androidRuntime)]
from missing-metadata-guava.
Hi @jjohannes,
I added a simple project that produces similar error https://github.com/MyDogTom/GuavaReproduce
Failure happens after executing ./gradlew app:testDebugUnitTest
.
from missing-metadata-guava.
I've just noticed that if I bump ExoPlayer dependency to 2.16.0, then the issue is gone. With ExoPlayer 2.15.1 version the build still fails. I've quickly scanned ExoPlayer 2.16.0 changelog. The only change that seems to be related is
Upgrade the WorkManager extension to depend on androidx.work:work-runtime:2.7.0.
Still I don't have enough knowledge to find a complete explanation :(
from missing-metadata-guava.
This fixed a build issue we were having, too - thanks @MyDogTom and @jjohannes!
from missing-metadata-guava.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from missing-metadata-guava.