• Hovhannes

    Hovhannes

    1 year ago
    Hello, everybody, I created an app with Hilt DI, but I'm new at DI. The app works well, but when I remove Hilt's annotations, the app works well again. How is possible? Can Hilt work without its annotations.
    Hovhannes
    Jeremy
    7 replies
    Copy to Clipboard
  • s

    Sergio C.

    1 year ago
    hi everyone I keep having this error but the hilt plugin is applied!
    Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin? (dagger.hilt.android.plugin)
    How can I solve it?
    s
    FunkyMuse
    +1
    5 replies
    Copy to Clipboard
  • Hovhannes

    Hovhannes

    1 year ago
    Hello everybody, I want to convert Dagger into Hilt, but I'm new at Hilt. I get these non  understandable errors. What mistakes did I make?  Thanks in advance.
    error: [Dagger/MissingBinding] com.example.feed.feedApp cannot be provided without an @Inject constructor or an @Provides-annotated method.
      public abstract static class SingletonC implements HiltWrapper_ActivityRetainedComponentManager_ActivityRetainedComponentBuilderEntryPoint,
                             ^
          com.example.feed.feedApp is injected at
              com.example.feed.dagger.viewmodel.FeedViewModelModule.providePauseAbleObservable(feedApp)
          com.example.feed.util.PauseAbleObservable<?> is injected at
              com.example.feed.viewmodel.FeedViewModel(�, PauseAbleObservable)
          com.example.feed.viewmodel.FeedViewModel is injected at
              com.example.feed.viewmodel.FeedViewModel_HiltModules.BindsModule.binds(vm)
          @dagger.hilt.android.internal.lifecycle.HiltViewModelMap java.util.Map<java.lang.String,javax.inject.Provider<androidx.lifecycle.ViewModel>> is requested at
              dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.ViewModelFactoriesEntryPoint.getHiltViewModelMap() [com.example.feed.feedApp_HiltComponents.SingletonC ? com.example.feed.feedApp_HiltComponents.ActivityRetainedC ? com.example.feed
    FeedViewModelModule.kt
    @Module
    @InstallIn(ActivityComponent::class)
    class FeedViewModelModule {
    
        @Provides
        fun providePauseAbleObservable(feedApp: FeedApp):  PauseAbleObservable<*> {
            return PauseAbleInterval(
                { System.currentTimeMillis() },
                sportsFeedApp.resources.getInteger(R.integer.pollingPeriodSeconds).toLong(),
                TimeUnit.SECONDS
            )
        }
    }
    PauseAbleObservable.kt
    interface PauseAbleObservable<T> {
         val observable: Observable<T>
    
        fun pause()
    
        fun resume()
    }
    FeedViewModel .kt
    @HiltViewModel
    class FeedViewModel @Inject constructor(
        private val feedRepository: FeedRepository,
        var pauseAbleObservable: PauseAbleObservable<*>
    ) : ViewModel() {....}
    Hovhannes
    a
    +1
    12 replies
    Copy to Clipboard
  • Hovhannes

    Hovhannes

    1 year ago
    Hello, I've a question about Hilt DI, but I'm new at Hilt. Can Hilt add automatically some annotations-@Inject, @AndroidEntryPoint, @HiltViewModel, if we don't mark with that annotations? When I don't mark with that annotations my app works.
    Hovhannes
    FunkyMuse
    3 replies
    Copy to Clipboard
  • Akram Bensalem

    Akram Bensalem

    1 year ago
    I always get this error:
    The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-android dependency was found.
    I wan't to use Hilt with Jetpack Compose but always I got this error
    Akram Bensalem
    solidogen
    +1
    33 replies
    Copy to Clipboard
  • m

    miqbaldc

    1 year ago
    https://github.com/google/dagger/issues/2752 anyone knows a workaround to provide a
    FragmentActivity
    for a qualifier of
    @ActivityContext
    using
    @Binds
    or it’s only possible to use the
    @Provides
    ?
    m
    t
    2 replies
    Copy to Clipboard
  • Colton Idle

    Colton Idle

    1 year ago
    Should I be able to @Provide a
    List
    ? e.g.
    @Provides
    fun provideRetrofit(interceptors: List<Interceptor>): MyApiService {
        return MyRetrofitServiceBuilder().build(interceptors, "http://...")
    }
    
    @Provides
    fun provideInterceptorList(@ApplicationContext context: Context): List<Interceptor> {
    ....
    getting an error though.
    error: [Dagger/MissingBinding] java.util.List<? extends okhttp3.Interceptor> cannot be provided without an @Provides-annotated method.
      public abstract static class SingletonC implements RollerToasterApplication_GeneratedInjector,
    Using an ArrayList instead works, but just curious if I'm missing something basic here.
    Colton Idle
    e
    +2
    12 replies
    Copy to Clipboard
  • rkeazor

    rkeazor

    1 year ago
    Hey does anyone know how to handle baseclasses with default values inhilt?
    rkeazor
    FunkyMuse
    3 replies
    Copy to Clipboard
  • brandonmcansh

    brandonmcansh

    1 year ago
    Hey guys posted this in #android but figured it might be better suited here:
    Hey guys hitting an issue trying to inject into a Worker with Hilt
    🧵
    brandonmcansh
    Jeremy
    8 replies
    Copy to Clipboard
  • rkeazor

    rkeazor

    1 year ago
    Hey how do you disable the hilt InstallIn Exception project wide?
    rkeazor
    1 replies
    Copy to Clipboard