Faithlife / AndroidLint

Android Lint checks to enforce Faithlife house rules
MIT License
2 stars 2 forks source link

Detect @Inject constructors on framework components #21

Open jzbrooks opened 1 year ago

jzbrooks commented 1 year ago

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.

The main value of this check is an explanation to engineers new to dagger why this is wrong. A quick fix should be doable for this. The detector and fix should work for both Java and Kotlin source.

jzbrooks commented 1 year ago

Ideally, this would be in the hilt library jar, because this rule (specifically the error description and quick fix) are only applicable if hilt is on the classpath.

https://github.com/google/dagger/issues/3749