a

    Ahmed Ibrahim

    2 years ago
    I'm wondering if anyone has started facing
    bindsMethod does not represent a type element
    issues when started migrating to Hilt? It never popped up before 😕
    Caused by: java.lang.IllegalArgumentException: bindsDateFormatter(com.example.date.SalesDateFormatter) does not represent a type element
            at dagger.shaded.auto.common.MoreElements$CastingElementVisitor.defaultAction(MoreElements.java:395)
            at dagger.shaded.auto.common.MoreElements$CastingElementVisitor.defaultAction(MoreElements.java:386)
            at com.sun.tools.javac.code.Symbol$MethodSymbol.accept(Symbol.java:1644)
            at dagger.shaded.auto.common.MoreElements.asType(MoreElements.java:128)
            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.ModuleProcessingStep.process(ModuleProcessingStep.java:104)
            at dagger.internal.codegen.ModuleProcessingStep.process(ModuleProcessingStep.java:59)
    And it is just bound using a simple
    @Binds
    @Binds
        abstract fun bindsDateFormatter(it: SalesDateFormatter): DateFormatter
    gildor

    gildor

    2 years ago
    Could you show the whole module?
    a

    Ahmed Ibrahim

    2 years ago
    Module(
        includes = [
            NetworkModule::class,        TimberLogTreeModule::class,
            DatabaseModule::class,
            FlipperModule::class,
            UiModule::class,
            ImageLoaderModule::class,
            TrackingModule::class,
            LocaleModule::class,
            ServiceModule::class,
            RepositoryModule::class,
            UseCaseModule::class,
    AssistedApplicationModule::class
        ]
    )
    @InstallIn(ApplicationComponent::class)
    abstract class ApplicationModule {
    
        @Binds
        abstract fun bindsDateFormatter(it: SalesDateFormatter): DateFormatter
    
        @Binds
        @IntoSet
        abstract fun bindsTrackingActivityLifecycleCallbacks(
            it: CurrentActivityProviderLifecycleCallbacks
        ): Application.ActivityLifecycleCallbacks
    
        @Binds
        abstract fun bindsActivityProvider(it: CurrentActivityProviderLifecycleCallbacks): ActivityProvider
    
        @Binds
        internal abstract fun bindsRootNavigator(it: MainNavigator.Factory): RootNavigator.Factory
    
        @ForApplication
        @Binds
        abstract fun bindsErrorNotifier(it: ToastErrorNotifier): ErrorNotifier
    
        companion object {
    
            @Provides
            fun provideAppDispatchers(): AppDispatchers = DefaultCoroutinesDispatcher
    
            @ApplicationLifetime
            @Singleton
            @Provides
            fun provideApplicationLifetimeCoroutineScope(appDispatchers: AppDispatchers) =
                CoroutineScope(SupervisorJob() + appDispatchers.default)
    
            @Provides
            fun providesGlobalClock(): Clock = Clock.systemUTC()
        }
    }
    I'm trying to migrate a quite big project.
    gildor

    gildor

    2 years ago
    Hmm, maybe it cannot resolve this class in classpath 🤔
    a

    Ahmed Ibrahim

    2 years ago
    This class is in another module, so I made sure that the
    :app
    has an
    implementation
    on that module that contains this class. But apparently that did nothing 🤔
    That's super weird I kept moving one
    @Binds
    statement after another from the
    ApplicationModule
    into another one among the
    includes
    and it worked 🤔
    a

    Arun

    2 years ago
    I came across this once in one of my projects. This might be possibly related to https://github.com/google/dagger/issues/970 I have meaning to create a minimal reproducible project to create issue with dagger team, haven’t gotten around it yet.
    a

    Ahmed Ibrahim

    2 years ago
    @Arun Thanks, I thought about filing a bug and creating a reproducible scenario in a project, but so far it's been not so straight forward to reproduce.
    a

    Arun

    2 years ago
    Thanks, I will try and update here if I succeed