You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed, that AboutStyler constructor has @Inject annotation, however at the same time AboutStyler is provided via @Provides from AboutActivityModule with @FeatureScope. Having looked at generated by Dagger source code, AboutStyler_Factory is not used anywhere and DaggerAboutComponent uses AboutActivityModule_ProvideAboutStylerFactory instead.
I removed @Inject annotation from AboutStyler and run ./gradlew :about:assembleDebug --profile. It seems everything is working, DaggerAboutComponent remained the same, but AboutStyler_Factory is not generated. Rough measurement on clean about module on my machine shew, that task :about:kaptDebugKotlin took 2.686s with @Inject and 2.299s without.
Moreover AboutActivity is already bounded in AboutComponent.Builder, so one can remove provideContext and provideAboutStyler from AboutActivityModule, keeping @Inject on AboutStyler. I also added @FeatureScope to AboutStyler class. This time generated AboutStyler_Factory is used by DaggerAboutComponent.
The question is: is it safe to remove @Inject annotation from AboutStyler or it's better to remove provide* methods from AboutActivityModule and keep @Inject annotation on AboutStyler constructor? Or we have to keep everything as it is, but we'll have generated unused AboutStyler_Factory. This should not be a problem since R8/Proguard will strip such classes, but I suppose it might decrease build time during development, if there are more such cases.
I can make all required changes if needed.
Thanks.
The text was updated successfully, but these errors were encountered:
You can safely remove the @Inject, unfortunately Dagger doesn't error out when there are two ways to provide a binding. Creating AboutStyler requires an activity instance, which isnt available in the graph and is passed in as a module param.
You can safely remove the @Inject, unfortunately Dagger doesn't error out when there are two ways to provide a binding. Creating AboutStyler requires an activity instance, which isnt available in the graph and is passed in as a module param.
I noticed, that
AboutStyler
constructor has@Inject
annotation, however at the same timeAboutStyler
is provided via@Provides
fromAboutActivityModule
with@FeatureScope
. Having looked at generated by Dagger source code,AboutStyler_Factory
is not used anywhere andDaggerAboutComponent
usesAboutActivityModule_ProvideAboutStylerFactory
instead.I removed
@Inject
annotation fromAboutStyler
and run./gradlew :about:assembleDebug --profile
. It seems everything is working,DaggerAboutComponent
remained the same, butAboutStyler_Factory
is not generated. Rough measurement on cleanabout
module on my machine shew, that task:about:kaptDebugKotlin
took 2.686s with@Inject
and 2.299s without.Moreover
AboutActivity
is already bounded inAboutComponent.Builder
, so one can removeprovideContext
andprovideAboutStyler
fromAboutActivityModule
, keeping@Inject
onAboutStyler
. I also added@FeatureScope
toAboutStyler
class. This time generatedAboutStyler_Factory
is used byDaggerAboutComponent
.Diff
The question is: is it safe to remove
@Inject
annotation fromAboutStyler
or it's better to removeprovide*
methods fromAboutActivityModule
and keep@Inject
annotation onAboutStyler
constructor? Or we have to keep everything as it is, but we'll have generated unusedAboutStyler_Factory
. This should not be a problem since R8/Proguard will strip such classes, but I suppose it might decrease build time during development, if there are more such cases.I can make all required changes if needed.
Thanks.
The text was updated successfully, but these errors were encountered: