Ahmed Ibrahim
06/15/2020, 10:03 AMbindsMethod 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
06/15/2020, 10:13 AMAhmed Ibrahim
06/15/2020, 10:17 AMModule(
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()
}
}
Ahmed Ibrahim
06/15/2020, 10:18 AMgildor
06/15/2020, 10:19 AMAhmed Ibrahim
06/15/2020, 10:20 AM:app
has an implementation
on that module that contains this class. But apparently that did nothing 🤔Ahmed Ibrahim
06/15/2020, 10:34 AM@Binds
statement after another from the ApplicationModule
into another one among the includes
and it worked 🤔Arun
06/15/2020, 12:43 PMAhmed Ibrahim
06/15/2020, 1:40 PMArun
06/15/2020, 4:37 PM