dagger-2

Hilt using in android library

为君一笑 提交于 2020-12-03 08:51:33
问题 I would like to try Hilt DI in the android library. It is a dependency on another project, with its own submodule. The very first problem I've encountered is the requirement of marking Application with @HiltAndroidApp . Now I do not have anything that extends Application in my library ofc but would like to utilize Hilt and its predefined components. Is it possible or should I go with Dagger only in such a case? I've found a solution for Dagger, where library dependency injection is made

Dagger 2 on Android. Different ways to store and access a @Singleton Component

泪湿孤枕 提交于 2020-12-02 06:40:42
问题 This is the Nth question about how to store @Singleton scoped Dagger 2 Components whose lifetime should equal the application's lifetime. In Android apps using Dagger 2 there is usually at least one Component which is @Singleton scoped and should last for all the application's lifetime: because of these requirements it is usually initialised and stored inside a custom Application class. Since the instance of this Component must be reachable in all parts of our Application I've seen code like

Create Custom Dagger 2 Scope with Kotlin

删除回忆录丶 提交于 2020-08-24 06:10:19
问题 I'm trying to convert a Java code into Kotlin for custom dagger scope creation. Here is Java code: @Documented @Scope @Retention(RetentionPolicy.RUNTIME) public @interface CustomScope { } Once converted into kotlin here is the result @Scope @Documented @Retention(RetentionPolicy.RUNTIME) annotation class CustomScope I have a type mismatch with @Retention(RetentionPolicy.RUNTIME) .I have the following error message :Required Type is AnnotationRetention but RetentionPolicy type was found. Also

Android Dynamic Feature modules with Dagger Hilt

坚强是说给别人听的谎言 提交于 2020-08-10 19:21:14
问题 I have built a Dynamic feature module sample with Fragments, sub components and dependent components based on plaid app, if you wish to check out here is the link. Now, i'm trying to convert it to Dagger Hilt using the official android document. In core module which is the library module, app module and dynamic feature modules depend on @Singleton @Component(modules = [CoreModule::class]) interface CoreComponent { /* Provision methods to provide dependencies below to components that depends