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

Hilt 2.39 compile fails when guava dependency is forced to an "-android" flavor #2904

Closed
scaires opened this issue Sep 30, 2021 · 0 comments · Fixed by #2905
Closed

Hilt 2.39 compile fails when guava dependency is forced to an "-android" flavor #2904

scaires opened this issue Sep 30, 2021 · 0 comments · Fixed by #2905

Comments

@scaires
Copy link

scaires commented Sep 30, 2021

After updating my project's hilt dependency to 2.39 last night, I noticed a build failure with the following stack trace. After investigating, it seemed as if this was an error with a method that is missing from the -android versions of guava. Looking into it a bit more, I noticed that in our project we had forced the guava dependency to an android specific flavor in resolutionStrategy in our build.gradle (first 28.2-android, then 31.0.1-android).

Eg:

    configurations.all {
        resolutionStrategy {
            force("com.google.guava:guava:31.0.1-android") // this resolution strategy causes a build failure
        }
    }

Either rolling back to hilt 2.38.1 or removing the guava forced resolution strategy allowed the project to compile. I'm not sure if this is intended behavior (or if there is another workaround) but I wanted to highlight it just in case!

I created a small repro project as well to show the build failure: https://drive.google.com/file/d/1y8qEc2Yk7T6buoCPCdmhej7DjhUb9jvK/view?usp=sharing

Versions:
android studio : Arctic Fox 2020.3.1
gradle plugin : 7.0.2
gradle : 7.0.2

Thank you!

Stack trace:

Caused by: com.sun.tools.javac.processing.AnnotationProcessingError: java.lang.NoSuchMethodError: 'java.util.stream.Collector com.google.common.collect.ImmutableSet.toImmutableSet()'
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:992)
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:896)
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1222)
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1335)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1258)
	... 35 more
Caused by: java.lang.NoSuchMethodError: 'java.util.stream.Collector com.google.common.collect.ImmutableSet.toImmutableSet()'
	at dagger.hilt.android.processor.internal.androidentrypoint.Generators.copySuppressAnnotations(Generators.java:160)
	at dagger.hilt.android.processor.internal.androidentrypoint.InjectorEntryPointGenerator.generate(InjectorEntryPointGenerator.java:64)
	at dagger.hilt.android.processor.internal.androidentrypoint.AndroidEntryPointProcessor.processEach(AndroidEntryPointProcessor.java:56)
	at dagger.hilt.processor.internal.BaseProcessor.process(BaseProcessor.java:194)
	at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt:90)
	at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:175)
	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:980)
	... 39 more
copybara-service bot pushed a commit that referenced this issue Sep 30, 2021
In a follow-up, I'll look into why none of our METADATA or presubmit checks caught this and add a fix to prevent this in the future.

Fixes #2904

RELNOTES=Fix #2904: Change toImmutableSet to use DaggerStreams rather than Guava.
PiperOrigin-RevId: 400011572
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant