Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocker (regression in 6.1.2): "Unable to find method 'com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector;'" #3221

Closed
alwa opened this issue Mar 24, 2021 · 9 comments
Labels
Milestone

Comments

@alwa
Copy link

alwa commented Mar 24, 2021

Describe the bug
Cannot evaluate Gradle project. My project uses Android Gradle Plugin version 4.1.2, Gradle version 6.8.3 and Jdk version 11.

Version of dependency-check used
The problem occurs using version 6.1.2 (and 6.1.3) of the gradle plugin. It works fine in 6.1.1 and below.

Log file

Unable to find method 'com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector;'
com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector;
@alwa alwa added the bug label Mar 24, 2021
@alwa alwa changed the title Regression in 6.1.2: "Unable to find method 'com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector;'" Blocker (regression in 6.1.2): "Unable to find method 'com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector;'" Mar 24, 2021
@jeremylong
Copy link
Owner

Looks like a dependency conflict in your build environment. No where in ODC is toImmutableList() called: https://github.com/jeremylong/DependencyCheck/search?q=toImmutableList

Pretty sure ODC can use Guava [24.1.1,]

@alwa
Copy link
Author

alwa commented Mar 24, 2021

Ok thanks. I will investigate on my side.

@jeremylong
Copy link
Owner

In ODC 6.1.4 - I explicitly set the version of Guava to be 24.1.1-jre as opposed to using a version range.

@alwa
Copy link
Author

alwa commented Mar 24, 2021

I've looked through the gradle dependencies and I don't have any clear conclusion.
I have a transitive dependency to Guava (different version) through a test library called Robolectric but there is apparantly also a (unspecified) direct dependency :

releaseUnitTestCompileClasspath - Resolved configuration for compilation for variant: releaseUnitTest
...
+--- com.google.guava:guava:{strictly 27.0.1-jre} -> 27.0.1-jre (c)

Related:
https://stackoverflow.com/questions/54635950/android-x-truth-guava-test-compile-issue
google/error-prone#528
google/dagger#1700

I have not tried any of the workarounds like adding a direct dependency in my project. It feels like a hack to do so.

@alwa
Copy link
Author

alwa commented Mar 24, 2021

I've attached the output from my projects dependencies. Note: This is performed using version 6.1.1 of the ODC.

dependency-tree.txt

@alwa
Copy link
Author

alwa commented Mar 25, 2021

I've created a new sample Android project (using the tutorial in Android Studio) and can reproduce the issue easily without adding more code than the reference to the ODC in the plugin section (build.gradle):

MyApplication.zip

To reproduce the issue:

  1. Download Android Studio 4.1.3, https://developer.android.com/studio
  2. In Android Studio:
  • Import attached sample project "MyApplication"
  • Choose from dropdown menu: File -> Sync Project with Gradle Files

Expected:
Project resolved OK

Actual:
Error:

Unable to find method 'com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector;'
com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector;

@jeremylong
Copy link
Owner

@alwa One solution is to strictly enforce the use of Guava 28.1-jre:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath('com.google.guava:guava'){
            version {
                strictly '28.1-jre'
            }
        }
        classpath "com.android.tools.build:gradle:4.1.3"
        classpath("org.owasp:dependency-check-gradle:6.1.3") 
    }
}

@alwa
Copy link
Author

alwa commented Mar 26, 2021

@jeremylong this ticket looks like a duplicate of dependency-check/dependency-check-gradle#213
I'll proceed and close this one if you agree.

As for the provided workaround I don't think it's very appealing to leak dependency information but I guess you had your reasons to enforce strictness on Guava and that there is no way to prevent this from leaking?

@jeremylong jeremylong added this to the 6.1.4 milestone Mar 27, 2021
@jeremylong
Copy link
Owner

I just bumped guava to 30.1.1-jre via f861019 and retested with your sample project and everything works.

cbeams added a commit to bisq-network/bisq that referenced this issue Nov 21, 2021
This is a quick attempt to fix the issue described by @jmacxx in Keybase
similar to what's described at
jeremylong/DependencyCheck#3221.

It needs to be tested in the environment where the issue was observed
(Windows).
cbeams added a commit to cbeams/bisq that referenced this issue Nov 21, 2021
Problem: a

    NoSuchMethodError: 'java.util.stream.Collector
    com.google.common.collect.ImmutableMultiset.toImmutableMultiset()'

exception was being thrown when testing the previously-merged upgrade to
Gradle 7.3, as described at keybase://chat/bisq#testing/2466.

Solution: This problem is similar to the issue reported at
jeremylong/DependencyCheck#3221. The source of the problem was multiple
conflicting guava jars on the runtime classpath. This commit upgrades to
guava 30.1.1-jre which ensures a single jar on the classpath.
ripcurlx pushed a commit to bisq-network/bisq that referenced this issue Nov 21, 2021
Problem: a

    NoSuchMethodError: 'java.util.stream.Collector
    com.google.common.collect.ImmutableMultiset.toImmutableMultiset()'

exception was being thrown when testing the previously-merged upgrade to
Gradle 7.3, as described at keybase://chat/bisq#testing/2466.

Solution: This problem is similar to the issue reported at
jeremylong/DependencyCheck#3221. The source of the problem was multiple
conflicting guava jars on the runtime classpath. This commit upgrades to
guava 30.1.1-jre which ensures a single jar on the classpath.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants