Dependency Injection Usage Checks
DI checks is an annotation processor used to detect common issues when using dependency injection frameworks that use JSR 330 like Toothpick or Dagger.
When an issue is found compilation will fail.
Currently, the library has a single check that verifies a common programming error when using dependency injection: duplicating the same injection of the same dependency within a given hierarchy of types (i.e. a super class and a subclass perform the same injection, which is useless). This check is called DuplicateInjectionInHierarchy.
Just add the following line in your module’s gradle file to get started:
dependencies {
...
annotationProcessor "com.groupon.android.dichecks:compiler:1.0.2" <--- Add this to your dependencies.
...
}
You have fine grained control over checks with this pattern:
android {
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
arguments = [
...
'com.groupon.android.dichecks.duplicateCheck.failOnError': 'false', <--- Issue warnings instead of compiler errors.
'com.groupon.android.dichecks.duplicateCheck.enabled': 'true', <--- Enable or disable check completely.
...
]
}
}
}
}
We will add other useful checks related to dependency injection.