Category : dagger-hilt

Im investigating Dynamic Feature modules in my current Android Application. My application consists of an App Module, a number of static modules and a single Dynamic Feature Module. Im attempting to inject a repository class declared in the Dynamic Feature Module into a repository class in one of my static modules. I have a common ..

Read more

I want to setup two Retrofit2 clients with Dagger Hilt, because my application fetch informations from two different api’s. But when I run my code the following exception is thrown -> App_HiltComponents.java:128: error: [Dagger/DuplicateBindings] retrofit2.Retrofit is bound multiple times: public abstract static class SingletonC implements HiltWrapper_ActivityRetainedComponentManager_ActivityRetainedComponentBuilderEntryPoint, ^ @org.jetbrains.annotations.NotNull @Provides retrofit2.Retrofit de.kotlinbooks.di.NetworkBooksModule.retrofitBooks(okhttp3.OkHttpClient) @org.jetbrains.annotations.NotNull @Provides retrofit2.Retrofit de.kotlinbooks.di.NetworkNYTModule.retrofitNYT(okhttp3.OkHttpClient) ..

Read more

Model class data class GetNotification( @SerializedName("data") val data: MutableList, @SerializedName("_pagination") val pagination: Pagination, @SerializedName("status") val status: Boolean, @SerializedName("message") val message: String, @SerializedName("status_code") val statusCode: Int ) { data class Data( @SerializedName("booking_id") val bookingId: String, @SerializedName("company_id") val companyId: String, @SerializedName("created_on") val createdOn: String, @SerializedName("description") val description: String, @SerializedName("id") val id: String, @SerializedName("image") val image: String, @SerializedName("title") ..

Read more

Main Activity @AndroidEntryPoint class MainActivity : AppCompatActivity() { private lateinit var binding : ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) } Hilt Module @Module @InstallIn(SingletonComponent::class) class AppModule { @Singleton @Provides fun provideActivity(): MainActivity = MainActivity() @Singleton @Provides fun provideActivityUtils(@ActivityRetainedScoped context: MainActivity): ActivityUtils = ActivityUtilsImpl(context) } And utils class with needed functions ..

Read more

I’m using @ViewModelInject in my ViewModel as shown in below but now It’s deprecated so When I tried to use @HiltViewModel but I can’t use @ApplicationContext init. So my question is How to use common dependency which I annotated with @InstallIn(SingletonComponent::class) in @HiltViewModel ? How to use @ApplicationContext in @HiltViewModel , ViewModelComponent::class ? My code ..

Read more

I’m trying out the Hilt DI in my test project. I’ve the following module that’s installed in SingletonComponent which in terms of Android is applicationComponent. However when I try to scope the provide method with @Singleton, I get the following error. MyApplication_HiltComponents.ViewModelC repeats modules with scoped bindings or declarations: public abstract static class SingletonC implements ..

Read more