Giter Site home page Giter Site logo

Comments (10)

jjohannes avatar jjohannes commented on June 19, 2024 2

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.

jjohannes avatar jjohannes commented on June 19, 2024 1

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.

jjohannes avatar jjohannes commented on June 19, 2024

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.

MyDogTom avatar MyDogTom commented on June 19, 2024

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.

jjohannes avatar jjohannes commented on June 19, 2024

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.

MyDogTom avatar MyDogTom commented on June 19, 2024

Gradle 7.3.3 and AGP 7.0.4.

from missing-metadata-guava.

MyDogTom avatar MyDogTom commented on June 19, 2024

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.

MyDogTom avatar MyDogTom commented on June 19, 2024

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.

MyDogTom avatar MyDogTom commented on June 19, 2024

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.

jeff-huston avatar jeff-huston commented on June 19, 2024

This fixed a build issue we were having, too - thanks @MyDogTom and @jjohannes!

from missing-metadata-guava.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.