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

2.26: ClassNotFoundException: com.google.common.collect.MoreCollectors #1740

Closed
yogurtearl opened this issue Feb 12, 2020 · 2 comments · Fixed by #1744
Closed

2.26: ClassNotFoundException: com.google.common.collect.MoreCollectors #1740

yogurtearl opened this issue Feb 12, 2020 · 2 comments · Fixed by #1744

Comments

@yogurtearl
Copy link

yogurtearl commented Feb 12, 2020

Kapt error with 2.26: ClassNotFoundException: com.google.common.collect.MoreCollectors

It compiles fine with 2.25.4 but errors with 2.26
Kotlin 1.3.61
Gradle 6.1.1
AGP 3.6rc3

e: java.lang.IllegalStateException: failed to analyze: java.lang.reflect.InvocationTargetException
        at org.jetbrains.kotlin.analyzer.AnalysisResult.throwIfError(AnalysisResult.kt:56)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:182)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:165)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:55)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1558)
        at jdk.internal.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:76)
        at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:35)
        at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:224)
        at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:187)
        at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:98)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:97)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:107)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:82)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:557)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:82)
        at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:548)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:177)
        ... 22 more
Caused by: com.sun.tools.javac.processing.AnnotationProcessingError: java.lang.NoClassDefFoundError: com/google/common/collect/MoreCollectors
        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:1334)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1258)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1157)
        ... 39 more
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/MoreCollectors
        at dagger.internal.codegen.kotlin.KotlinMetadataUtil.lambda$getEnclosedCompanionObject$2(KotlinMetadataUtil.java:105)
        at java.base/java.util.Optional.map(Optional.java:265)
        at dagger.internal.codegen.kotlin.KotlinMetadataUtil.getEnclosedCompanionObject(KotlinMetadataUtil.java:100)
        at dagger.internal.codegen.validation.ModuleValidator.validateCompanionModule(ModuleValidator.java:654)
        at dagger.internal.codegen.validation.ModuleValidator.validateUncached(ModuleValidator.java:248)
        at dagger.internal.codegen.validation.ModuleValidator.lambda$validate$0(ModuleValidator.java:179)
        at dagger.internal.codegen.base.Util.reentrantComputeIfAbsent(Util.java:33)
        at dagger.internal.codegen.validation.ModuleValidator.validate(ModuleValidator.java:179)
        at dagger.internal.codegen.validation.ModuleValidator.validate(ModuleValidator.java:173)
        at dagger.internal.codegen.ModuleProcessingStep.process(ModuleProcessingStep.java:121)
        at dagger.internal.codegen.ModuleProcessingStep.process(ModuleProcessingStep.java:59)
        at dagger.internal.codegen.validation.TypeCheckingProcessingStep.lambda$process$0(TypeCheckingProcessingStep.java:51)
        at java.base/java.util.Map.forEach(Map.java:661)
        at dagger.internal.codegen.validation.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:48)
        at dagger.internal.codegen.ModuleProcessingStep.process(ModuleProcessingStep.java:104)
        at dagger.internal.codegen.ModuleProcessingStep.process(ModuleProcessingStep.java:59)
        at dagger.internal.codegen.statistics.DaggerStatisticsCollectingProcessingStep.process(DaggerStatisticsCollectingProcessingStep.java:52)
        at dagger.shaded.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:330)
        at dagger.shaded.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:181)
        at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt)
        at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:147)
        at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:980)
        ... 44 more
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.MoreCollectors
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 66 more
@danysantiago
Copy link
Member

This is a regression of #1700, sorry 😞

You can workaround this by having com.google.guava:guava:28.1-jre in your processor classpath if possible.

@yogurtearl
Copy link
Author

oh, thanks for the pointer, we had something like this and it was also affecting the version of guava used for annotation processors.

allprojects { project ->

  configurations.all { configuration ->
    resolutionStrategy {
           force "com.google.guava:guava:28.1-android"
     }
  }
}

I don't think this is a dagger problem, so will close the issue.

kluever pushed a commit that referenced this issue Feb 17, 2020
Fixes #1740

RELNOTES=Remove a usage of Guava API not available in the '-android' variant.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=295026567
kluever pushed a commit that referenced this issue Feb 17, 2020
Fixes #1740

RELNOTES=Remove a usage of Guava API not available in the '-android' variant.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=295026567
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants