Dagger: NoSuchElementException when used in same module as Jetpack Compose

Created on 9 Jun 2020  路  2Comments  路  Source: google/dagger

I'm not 100% on the cause of this, but my guess is that this is due to some of my modules using Jetpack Compose (and therefore the IR compiler), and some are not.

I've tried updating my whole project to Kotlin 1.4-M2 and get the same error.

Repro:

git clone -b cb/merge-compose-modules [email protected]:chrisbanes/tivi.git
cd tivi
./gradlew assembleDebug

Log:

Caused by: java.util.NoSuchElementException                                                                                                                                                                                                   
        at dagger.internal.codegen.extension.DaggerCollectors$ToOptionalState.getElement(DaggerCollectors.java:145)                                                                                                                           
        at dagger.internal.codegen.extension.DaggerCollectors.lambda$static$1(DaggerCollectors.java:61)                                                                                                                                       
        at dagger.internal.codegen.kotlin.KotlinMetadata.findProperty(KotlinMetadata.java:131)                                                                                                                                                
        at dagger.internal.codegen.kotlin.KotlinMetadata.lambda$mapFieldToAnnotationMethod$5(KotlinMetadata.java:112)
        at dagger.internal.codegen.kotlin.KotlinMetadata.mapFieldToAnnotationMethod(KotlinMetadata.java:108)
        at dagger.internal.codegen.kotlin.KotlinMetadata.lambda$new$2(KotlinMetadata.java:100)
        at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:167)       
        at dagger.internal.codegen.kotlin.KotlinMetadata.isMissingSyntheticAnnotationMethod(KotlinMetadata.java:160)
        at dagger.internal.codegen.kotlin.KotlinMetadataUtil.isMissingSyntheticPropertyForAnnotations(KotlinMetadataUtil.java:76)
        at dagger.internal.codegen.validation.DependencyRequestValidator.checkQualifiers(DependencyRequestValidator.java:74)
        at dagger.internal.codegen.validation.DependencyRequestValidator.validateDependencyRequest(DependencyRequestValidator.java:67)
        at dagger.internal.codegen.validation.InjectValidator.validateDependencyRequest(InjectValidator.java:256)                                                                                                                             
        at dagger.internal.codegen.validation.InjectValidator.validateField(InjectValidator.java:212)
        at dagger.internal.codegen.validation.InjectValidator.validateMembersInjectionType(InjectValidator.java:268)
        at dagger.internal.codegen.validation.InjectBindingRegistryImpl.tryRegisterMembersInjectedType(InjectBindingRegistryImpl.java:280)
        at dagger.internal.codegen.validation.InjectBindingRegistryImpl.getOrFindMembersInjectionBinding(InjectBindingRegistryImpl.java:334)
        at dagger.internal.codegen.binding.BindingGraphFactory$Resolver.lookUpMembersInjectionBinding(BindingGraphFactory.java:437)
        at dagger.internal.codegen.binding.BindingGraphFactory$Resolver.resolveMembersInjection(BindingGraphFactory.java:852)    
        at dagger.internal.codegen.binding.BindingGraphFactory$Resolver.access$1200(BindingGraphFactory.java:299)
        at dagger.internal.codegen.binding.BindingGraphFactory.lambda$create$4(BindingGraphFactory.java:205)
        at dagger.internal.codegen.binding.BindingGraphFactory.create(BindingGraphFactory.java:202)                                                                                                                                           
        at dagger.internal.codegen.binding.BindingGraphFactory.create(BindingGraphFactory.java:230)
        at dagger.internal.codegen.binding.BindingGraphFactory.create(BindingGraphFactory.java:230)
        at dagger.internal.codegen.binding.BindingGraphFactory.create(BindingGraphFactory.java:109)
        at dagger.internal.codegen.ComponentProcessingStep.processRootComponent(ComponentProcessingStep.java:150)
        at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:131)
        at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:62)
        at dagger.internal.codegen.validation.TypeCheckingProcessingStep.lambda$process$0(TypeCheckingProcessingStep.java:51)
        at com.google.common.collect.RegularImmutableMap.forEach(RegularImmutableMap.java:185)
        at dagger.internal.codegen.validation.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:48)
        at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:124)
        at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:62)
        at dagger.internal.codegen.statistics.DaggerStatisticsCollectingProcessingStep.process(DaggerStatisticsCollectingProcessingStep.java:52)
        at dagger.shaded.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:330)

Most helpful comment

Just confirming in case anyone else hits this. Moving from lateinit to @Inject @JvmField var prop: Type? = null works for me.

All 2 comments

Closing this. @madsager investigated and found that this is a metadata issue in the current Kotlin compiler snapshot which Compose is currently using, when using @Inject lateinit var injectableProp.

(please correct me if I got that wrong @madsager)

Just confirming in case anyone else hits this. Moving from lateinit to @Inject @JvmField var prop: Type? = null works for me.

Was this page helpful?
0 / 5 - 0 ratings