Open jzbrooks opened 1 year ago
Similarly to #3729, we may build this in our lint library for now. I see a lot of value in upstreaming, however.
Note that you can constructor-inject activities and fragments with an app component factory and no Hilt: https://developer.android.com/reference/android/app/AppComponentFactory
Yep. That's why I'd rather the fix go into the hilt jar instead of a generic rule set like https://github.com/Faithlife/AndroidLint, that way hilt (love or hate it) use can be assumed.
Fragments, Activities, etc should use
@AndroidEntryPoint
to perform member injection.@Inject
constructs won't work here since the framework instantiates the components and dagger has no opportunity to provide constructor parameters.Add a lint detector (with a quick fix), which would help onboard engineers new to dagger and avoid easy mistakes that could be shipped in apps.
The hilt jar should provide this functionality if a hilt assumption is baked into the detector and fix.