Annotation Type HiltAndroidApp
-
@Retention(RUNTIME) @Target(TYPE) public @interface HiltAndroidApp
Annotation for marking theApplication
class where the Dagger components should be generated. Since all components will be built in the same compilation as the annotated application, all modules and entry points that should be installed in the component need to be transitive compilation dependencies of the annotated application.Usage of this annotation is similar to
AndroidEntryPoint
with the only difference being that it only works on application classes and additionally triggers Dagger component generation.This annotation will generate a base class that the annotated class should extend, either directly or via the Hilt Gradle Plugin. This base class will take care of injecting members into the Android class as well as handling instantiating the proper Hilt components at the right point in the lifecycle. The name of the base class will be "Hilt_
". Example usage (with the Hilt Gradle Plugin):
@HiltAndroidApp public final class FooApplication extends Application { @Inject Foo foo; @Override public void onCreate() { super.onCreate(); // The foo field is injected in super.onCreate() } }
Example usage (without the Hilt Gradle Plugin):
@HiltAndroidApp(Application.class) public final class FooApplication extends Hilt_FooApplication { @Inject Foo foo; @Override public void onCreate() { super.onCreate(); // The foo field is injected in super.onCreate() } }
- See Also:
AndroidEntryPoint
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.Class<?>
value
The base class for the generated Hilt application.
-