dagger-hilt

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

How to prevent Hilt from picking dependency from a library?

a 夏天 提交于 2020-08-09 08:17:06
问题 Okay, let's make this simple. I have created a simple library called my-network-library with two classes in it. First one is a Hilt module called BaseNetworkModule @Module @InstallIn(ApplicationComponent::class) object BaseNetworkModule { // Client @Singleton @Provides fun provideOkHttpClient(): OkHttpClient { return OkHttpClient.Builder() // my default okhttp setup goes here .build() } } and the second one is a simple class. class MyAwesomeClass { fun doMagic() { // magic code goes here } }

Dagger-Hilt: @ViewModelInject is not injecting MyViewModel and crash?

倾然丶 夕夏残阳落幕 提交于 2020-08-07 05:36:08
问题 In exploring the ViewModelInject of Dagger-Hilt, I follow the example in https://developer.android.com/training/dependency-injection/hilt-jetpack#viewmodels I try to inject the ViewModel into my activity as follow import android.app.Application import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import androidx.activity.viewModels import androidx.hilt.Assisted import androidx.hilt.lifecycle.ViewModelInject import androidx.lifecycle.* import androidx.savedstate