question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Couldn't resolve class for" error when generating a class with @ContributesMultibinding

See original GitHub issue

Version 2.3.11-1-6-10

I’m generating a class like this in an Anvil plugin:

@NavEntryComponentGetterKey(TrainingScope::class)
@ContributesMultibinding(
  Singleton::class,
  NavEntryComponentGetter::class
)
public class TrainingScopeComponentGetter @Inject constructor() : NavEntryComponentGetter {
}

Then Anvil fails with this error:

e: com.squareup.anvil.compiler.api.AnvilCompilationException: Back-end (JVM) Internal error: Couldn't resolve class for com.freeletics.app.TrainingScopeComponentGetter.
File being compiled: (72,1) in /com/freeletics/app/WhetstoneNavEntryTrainingScope.kt

        at com.squareup.anvil.compiler.internal.PsiUtilsKt.requireClassDescriptor(PsiUtils.kt:808)
        at com.squareup.anvil.compiler.codegen.ContributesMultibindingGeneratorKt.checkNotMoreThanOneMapKey(ContributesMultibindingGenerator.kt:111)
        at com.squareup.anvil.compiler.codegen.ContributesMultibindingGeneratorKt.access$checkNotMoreThanOneMapKey(ContributesMultibindingGenerator.kt:1)
        at com.squareup.anvil.compiler.codegen.ContributesMultibindingGenerator$generateCode$2.invoke(ContributesMultibindingGenerator.kt:55)
        at com.squareup.anvil.compiler.codegen.ContributesMultibindingGenerator$generateCode$2.invoke(ContributesMultibindingGenerator.kt:52)
        at kotlin.sequences.SequencesKt___SequencesKt$onEach$1.invoke(_Sequences.kt:1978)
        at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
        at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
        at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:786)
        at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(_Sequences.kt:816)
        at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:807)
        at com.squareup.anvil.compiler.codegen.ContributesMultibindingGenerator.generateCode(ContributesMultibindingGenerator.kt:100)
        at com.squareup.anvil.compiler.codegen.CodeGenerationExtension.analysisCompleted$generateCode(CodeGenerationExtension.kt:96)
        at com.squareup.anvil.compiler.codegen.CodeGenerationExtension.analysisCompleted(CodeGenerationExtension.kt:136)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:112)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:122)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:96)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:262)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:53)
        at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:113)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:253)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:100)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:58)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:170)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:92)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1618)
        at jdk.internal.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
        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(AccessController.java:712)
        at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)

The error looks similar very similar to #462 just with a different annotation. If it’s needed I can create a reproducer.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
vRallevcommented, Jan 31, 2022

I filed #479 for the 2nd issue and have a fix ready. The first issue is obviously a bug.

0reactions
vRallevcommented, Feb 16, 2022

We do many refactoring at the moment, the release will take a while unfortunately.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with Multibinding - cannot be provided without an ...
I'm trying to use the multi binding, but i'm getting the following error: error: [Dagger/MissingBinding] java.util.Map<java.lang.
Read more >
Inline MultiBinding not working as expected - Stack Overflow
Then we can fix it like this: public class MultiBinder : MultiBinding { public MultiBinder(BindingBase b1, BindingBase b2, object converter = null) ...
Read more >
Advanced Dagger Semantics
For any members-injectible class, Dagger generates a synthetic binding with key signature ... Multibinding methods are either declarations or contributions.
Read more >
Injector API reference — Injector 0.20.1 documentation
This class is instantiated internally for you and there's no need to ... and trying to bind them here will result in an...
Read more >
Fixed Error cannot find symbol class in Data Binding - YouTube
Need Help or Code Support? Feel Free To Contact Us Here http://www.aaviskar.com/support.phpThis is tutorial to fix Error cannot find symbol ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found